Commit graph

90 commits

Author SHA1 Message Date
Bryan Helmkamp
480364c2b0 Add flow-control data to STAGE_COMPLETED event
Add status, preferred_label, and suggested_next_ids fields to the
StageCompleted event so pipeline flow decisions are visible in CLI
output and the web UI, making it easier to debug why a pipeline
took a particular path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:32:42 -05:00
Bryan Helmkamp
95a4ab24d5 Thread EngineServices through Handler::execute() to eliminate circular dependency
ParallelHandler and SubPipelineHandler needed Arc<HandlerRegistry> at
construction time but also lived inside the registry, creating a circular
dependency. The previous fix special-cased ParallelHandler as a separate
field on PipelineEngine with a resolve_handler() override.

Instead, add an EngineServices struct (registry + emitter) passed through
Handler::execute(). ParallelHandler and SubPipelineHandler become unit
structs that get what they need at execution time. No special-casing,
both register normally in default_registry() like every other handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:31:55 -05:00
Bryan Helmkamp
74a6b219cc Fix spec: FAIL does not trigger retries, only RETRY does
The test criteria incorrectly said FAIL outcomes should be retried.
The pseudocode (Section 3.5) and the C reference implementation both
return immediately on FAIL. Only RETRY status triggers the retry loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:19:10 -05:00
Bryan Helmkamp
9f9b461971 Restore exactly-one terminal node validation per spec
The spec says "exactly one" exit node in the shape table (line 184),
exit handler docs (line 648), and test criteria (line 1834). The lint
rule table (line 1437) says "at least one" but is the minority. The
previous commit incorrectly reverted this — the terminal node change
was not causing the test failures (all three were from retry-on-Fail).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:12:45 -05:00
Bryan Helmkamp
6406fccd19 Fix regressions from ceaa9bf: restore Fail as non-retryable and allow multiple terminal nodes
Revert two incorrect behavioral changes introduced in ceaa9bf:

1. StageStatus::Fail must return immediately, not retry. Fail is a
   deliberate routing outcome (e.g. to take a "fail" edge). Retrying it
   caused conditional_branching and manager_loop tests to hang.

2. Pipelines can legitimately have multiple terminal nodes. The
   "exactly one" constraint broke branching_loop_back_on_failure.
   Restore "at least one" validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:09:36 -05:00
Bryan Helmkamp
06480db417 Register parallel handler to prevent dry-run hang on parallel pipelines
The parallel handler was never registered in default_registry() due to a
circular dependency (ParallelHandler::new needs Arc<HandlerRegistry>).
Break the cycle by storing ParallelHandler as a separate field on
PipelineEngine, created after Arc-wrapping the registry and emitter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 16:04:16 -05:00
Bryan Helmkamp
ceaa9bf560 Improve session abort handling, emit tool output deltas, and tighten validation
- Break out of streaming loop on abort and drop the stream before emitting
  SessionEnd to properly cancel the HTTP connection
- Emit ToolCallOutputDelta events for tool call results in both sequential
  and parallel execution paths
- Retry on StageStatus::Fail in addition to Retry in pipeline engine
- Set preferred_label on WaitHumanHandler choice outcomes
- Enforce exactly one terminal node in pipeline validation
- Downgrade unreachable node diagnostic from Error to Warning
- Update context window test to match 1M token limit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 15:39:04 -05:00
Bryan Helmkamp
834b7f6160 Display relative paths in CLI tool call output
Strip the CWD prefix from string arguments in format_tool_args so tool
call output shows relative paths instead of absolute ones.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:53:19 -05:00
Bryan Helmkamp
9ddb325390 Clarify spec-dod-multimodel prompts to respond with JSON inline instead of writing files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:46:03 -05:00
Bryan Helmkamp
6071bb0aa7 Handle signature_delta streaming event for Anthropic thinking blocks
The Anthropic streaming API sends thinking block signatures via a
signature_delta event, not in content_block_start or content_block_stop.
The parser was ignoring this event type, falling back to the empty
placeholder signature from content_block_start, causing "Invalid
signature in thinking block" errors on multi-turn conversations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:39:42 -05:00
Bryan Helmkamp
9342b5be76 Preserve thinking block signatures for Anthropic multi-turn conversations
The Anthropic API requires a `signature` field on thinking blocks when
they are sent back in conversation history. Previously, thinking blocks
were stored as plain text in Turn::Assistant.reasoning, losing the
signature. Now Thinking/RedactedThinking content parts are preserved
in provider_parts (which retains signatures), and the lossy
reconstruction path is skipped when provider_parts already contains
thinking blocks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:37:12 -05:00
Bryan Helmkamp
6fee3d82f1 Parse routing directives from LLM response text in CodergenHandler
When CodergenHandler receives CodergenResult::Text, it now extracts
preferred_next_label, suggested_next_ids, and context_updates from
the last JSON object in the response. This enables edge selection
via condition matching and preferred label instead of always falling
through to unconditional edges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:31:35 -05:00
Bryan Helmkamp
242e82fffd Use Claude Opus 4.6 with 1M context window as default Anthropic model
Switch default model from claude-sonnet-4-5 to claude-opus-4-6 across
run and serve commands. Enable the 1M token context window via the
context-1m-2025-08-07 beta header for opus-4-6 requests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:23:45 -05:00
Bryan Helmkamp
4f31a84ee6 Skip OpenAI function calls with empty names to avoid model-internal items
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:07:23 -05:00
Bryan Helmkamp
e52b19d1ce Clarify spec-dod prompts to respond with JSON inline instead of writing files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:05:30 -05:00
Bryan Helmkamp
f4f58078de Update default Gemini model to gemini-3.1-pro-preview and print model name on startup
Updates the default Gemini model from gemini-3-pro-preview to
gemini-3.1-pro-preview across agent, attractor, and ullm CLIs.
Adds "Using model:" output to stderr in both agent and ullm CLIs
so users can see which model is being used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 14:05:16 -05:00
Bryan Helmkamp
366643d6ef Add attractor-web React frontend for pipeline dashboard
Bun-based React app with pipeline dashboard UI including event log,
graph view, context/checkpoint panels, question panel, and status bar.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:47:03 -05:00
Bryan Helmkamp
b4f65e2555 Increase stream_read timeout from 30s to 120s
Prevents premature timeouts on slower streaming responses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:46:32 -05:00
Bryan Helmkamp
e64c0a3328 Switch default model to claude-opus-4-6 and use adaptive thinking
Updates the default Anthropic model from claude-sonnet-4-5 to
claude-opus-4-6 and replaces beta headers with adaptive thinking
provider options for 4.6 models.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:46:31 -05:00
Bryan Helmkamp
379e90c11d Add --docker flag to attractor run and serve commands
When --docker is passed, agent tools execute inside a Docker container
via DockerExecutionEnvironment instead of running on the host. The host
working directory is bind-mounted into the container at /workspace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:42:10 -05:00
Bryan Helmkamp
ffa92cd23d Add GET /pipelines endpoint and pipeline list UI
Adds a list endpoint that returns all in-memory pipelines with their
status, and a "Recent Pipelines" section in the start form that polls
every 3s so users can navigate to any pipeline started since server launch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:39:28 -05:00
Bryan Helmkamp
e0f33e072e Fix Dockerfile.agent to use apt ripgrep for multi-arch support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:31:19 -05:00
Bryan Helmkamp
60dad3c1cd Add DockerExecutionEnvironment for sandboxed agent tool execution
Implements ExecutionEnvironment trait backed by Docker containers via
bollard. Host working directory is bind-mounted; all file ops, commands,
grep, and glob execute inside the container via docker exec. Extracts
shared format_lines_numbered() helper from LocalExecutionEnvironment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:29:38 -05:00
Bryan Helmkamp
86935bbb2b Expose MultipleChoice options in API and support selected answers
ApiQuestion now includes options and allow_freeform fields so API clients
can render multiple-choice questions. submit_answer accepts an optional
selected_option_key to produce AnswerValue::Selected instead of always
creating AnswerValue::Text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:28:36 -05:00
Bryan Helmkamp
e4fc345912 Switch agent session from complete() to stream() to avoid request timeouts
Long Opus responses hit the 120s request timeout with complete(). With
stream(), the request timeout only covers initial connection + first
chunk, then the 30s stream_read timeout guards against stalls between
chunks. Also emits AssistantTextDelta events during streaming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 13:10:54 -05:00
Bryan Helmkamp
dba48f866e Fix CodergenHandler swallowing retryable errors, preventing engine retries
The handler was converting all backend errors into Ok(Outcome::fail(...)),
which the engine treats as a terminal result. Retryable errors (timeouts,
network failures) are now propagated as Err so the engine retry loop kicks in.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 12:43:48 -05:00
Bryan Helmkamp
5573e0e8a2 Fix truncated LLM responses by populating catalog max_output
Requests were always sent with max_tokens: None, which defaulted to
4096 in the Anthropic provider, causing large outputs to be truncated.
Now build_request() looks up the model's max_output from the catalog
and passes it through, giving each model its full output capacity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 12:30:25 -05:00
Bryan Helmkamp
3a70e6711c serve 2026-02-23 12:20:48 -05:00
Bryan Helmkamp
dddc6df8c8 Extract terminal crate and prettify attractor CLI output
Move ANSI Styles struct from agent/cli.rs into a shared terminal crate
so both binaries can use it. Add green and yellow color codes. Prettify
all attractor CLI output: bold headers, colored diagnostics by severity,
green/red status, yellow warnings, dimmed event details, and styled
interviewer prompts. Move pipeline status output from stdout to stderr.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 12:06:24 -05:00
Bryan Helmkamp
b4397564ec Prettify agent CLI stderr output with ANSI colors
Add a Styles struct that pre-resolves ANSI escape codes based on whether
stderr is a TTY. Tool calls show as "● tool_name(args)" with bold+cyan
names, errors use red "✗", summaries are dimmed, and debug/verbose
middleware output is styled. No ANSI codes emitted when piped.

Also passes tool call arguments through to EventData::ToolCall so the
event handler can format them inline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 11:45:13 -05:00
Bryan Helmkamp
df8502d83b Merge agent-cli crate into agent as cli module
The agent-cli binary was a thin wrapper over the agent library with
nothing else depending on it. Moving it into the agent crate as a
`pub mod cli` with a `[[bin]]` entry reduces workspace complexity
and follows the attractor crate pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 11:14:25 -05:00
Bryan Helmkamp
eaf934f355 Add tests for tool_approval and agent-cli
- 5 session tests exercising ToolApprovalFn callback (deny, allow,
  arg capture, None passthrough, error event emission)
- 18 unit tests for agent-cli pure functions (tool_category,
  is_auto_approved, default_model, validate_api_key,
  build_tool_approval, build_profile)
- 4 integration tests for the agent binary (usage, help, missing
  API key, invalid permissions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 11:05:44 -05:00
Bryan Helmkamp
0edc93e1c3 Add CLI tests for validate and dry-run on all test workflows
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:58:54 -05:00
Bryan Helmkamp
f6bf30de3e Disable empty doc-tests and add terse test output alias
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:57:26 -05:00
Bryan Helmkamp
4915574f96 Preserve provider-specific content parts across agent turns
The agent's Turn::Assistant decomposed responses into text, tool_calls,
and reasoning fields, discarding ContentPart::Other items. This lost
OpenAI reasoning items needed for Responses API round-tripping.

Add provider_parts field to Turn::Assistant to carry opaque content
parts through the history, and emit them first in convert_to_messages
so they precede function_call items as the API requires.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:54:35 -05:00
Bryan Helmkamp
b7883d6bef Add agent CLI with tool approval callback
Introduce `ToolApprovalFn` callback in `SessionConfig` to gate tool
execution by permission level. Create `agent-cli` crate as a thin CLI
binary wrapping `Session` with provider/model resolution, permission
model (read-only/read-write/full), interactive approval prompts,
real-time event rendering, debug middleware, and SIGINT handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:50:40 -05:00
Bryan Helmkamp
17a42d19f2 Preserve OpenAI reasoning items for Responses API round-trip
The Responses API requires that reasoning items (type: "reasoning",
id: "rs_xxx") are included alongside their associated function_call
items when replaying conversation history. Without them:
"function_call was provided without its required 'reasoning' item"

Store reasoning output items as ContentPart::Other and replay them
as raw input items in translate_input. Handles both non-streaming
(parse_output) and streaming (handle_output_item_done) paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:30:39 -05:00
Bryan Helmkamp
6e15d602d0 Fix OpenAI Responses API function call ID prefix mismatch
The Responses API returns two distinct IDs on function_call items:
- `id` (item-level, starts with `fc_`)
- `call_id` (call-level, starts with `call_`)

When sending function calls back as input, the `id` field must start
with `fc_`. Previously we used `call_id` for both fields, causing:
"Invalid 'input[1].id': Expected an ID that begins with 'fc'."

Now we preserve the item-level `id` in provider_metadata and use it
for the `id` field, while `call_id` continues to link tool results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:27:24 -05:00
Bryan Helmkamp
e992b57ced Add regression tests for Anthropic beta headers and Gemini thought_signature
Covers two recent runtime failures that lacked test coverage:
- Anthropic: assert deprecated beta header values are not sent
- Gemini: test function call parsing/translation with and without thoughtSignature

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:22:14 -05:00
Bryan Helmkamp
94326f5438 docs/specs 2026-02-23 10:17:40 -05:00
Bryan Helmkamp
3b1411a3ac Preserve Gemini thought_signature on function calls
Gemini 3 models include a thoughtSignature field on function call
parts that must be returned in subsequent conversation turns. Add
provider_metadata to ToolCall to carry this through, and extract/emit
it in both the non-streaming and streaming Gemini code paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:14:19 -05:00
Bryan Helmkamp
7dddc49121 Remove deprecated anthropic-beta header values
The `extended-thinking-2025-04-14` and `max-tokens-3-5-sonnet-2025-04-14`
beta headers are no longer accepted by the Anthropic API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 10:05:43 -05:00
Bryan Helmkamp
d3e396753c Remove stale review docs, add spec DoD pipeline definitions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:47:50 -05:00
Bryan Helmkamp
4bb2de5a49 Rename unified-llm crate to llm
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:22:14 -05:00
Bryan Helmkamp
023cc54fed Merge unified-llm-cli crate into unified-llm
Move the ullm binary from a separate crate into unified-llm as
src/bin/ullm.rs, consolidating CLI dependencies into the library crate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:18:41 -05:00
Bryan Helmkamp
30cf3a6787 Rename coding-agent-loop crate to agent
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:17:48 -05:00
Bryan Helmkamp
5932b500e7 Implement GET /pipelines/{id}/graph endpoint for SVG rendering
Stores DOT source in ManagedPipeline and pipes it through `dot -Tsvg`
on request. Returns image/svg+xml on success, 502 if graphviz is
unavailable, 404 if pipeline not found. Resolves spec gap #1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:13:36 -05:00
Bryan Helmkamp
55b6000374 Fix OpenAI streaming returning no output for reasoning models
The SSE stream terminated prematurely when a network chunk contained
only unhandled event types (e.g. response.in_progress, reasoning
output_item.added). dispatch_sse_messages returned an empty vec, which
the unfold interpreted as stream-end. Now continues reading when
dispatch produces no StreamEvents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:12:40 -05:00
Bryan Helmkamp
433a7c6247 Implement attractor CLI binary with run and validate subcommands
Add a [[bin]] target to the attractor crate with two subcommands:
- `attractor validate <pipeline.dot>` -- parse and validate only
- `attractor run <pipeline.dot>` -- full pipeline execution with LLM backend

The CLI supports --dry-run, --auto-approve, --resume, --model, --provider,
and two-level verbosity (-v one-line summaries, -vv full event details).

Extracts a shared `default_registry()` function in handler/mod.rs so both
the CLI and server can build a fully-wired HandlerRegistry without
duplicating handler registration boilerplate.

The AgentBackend in cli/backend.rs implements CodergenBackend by creating
a coding-agent-loop Session per node invocation, giving LLM nodes access
to file and shell tools.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 09:11:42 -05:00
Bryan Helmkamp
54d0c887dc Add end-to-end test for subgraph class derivation, update spec gap analysis
Closes the subgraph class derivation test gap by adding a parse() pipeline
test that verifies DOT subgraph labels produce correct CSS-like classes on
contained nodes. Updates gap analysis to remove resolved items, add spec
contradictions section, and narrow remaining gaps to SVG rendering and
retry predicate customization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 08:39:42 -05:00