Implement executable tool functions for factory agent#4302
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Implements a new ActionDispatcher for applying AgentAction[] side-effects (realm writes + tool invocations) and enhances the software-factory harness to be more self-sufficient in fresh worktrees (auto-building/symlinking dist artifacts, improved template build progress reporting, and more resilient cached-context validation).
Changes:
- Added
factory-action-dispatcher.tsplus a comprehensive QUnit test suite covering routing, auth, signals, tool delegation, and error isolation. - Updated harness startup/template-building flow to auto-build/symlink required dist artifacts and to report indexing progress via worker-manager’s
/_indexing-status. - Simplified/remodeled worker-manager port handling (dynamic by default; optional explicit port for monitoring) and improved stale cached context URL validation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/software-factory/scripts/lib/factory-action-dispatcher.ts | New dispatcher that executes AgentAction side effects (writes/tools/signals) across target/test realms. |
| packages/software-factory/tests/factory-action-dispatcher.test.ts | New unit tests covering dispatcher routing, auth, tool execution, signals, and error isolation. |
| packages/software-factory/tests/fixtures.ts | Removes fixed worker-manager port allocation/env wiring in test fixture setup. |
| packages/software-factory/src/harness/support-services.ts | Adds auto symlink/build paths for host + boxel-ui/boxel-icons dist; adjusts icon server lifecycle management. |
| packages/software-factory/src/harness/shared.ts | Removes DEFAULT_WORKER_MANAGER_PORT env-derived constant. |
| packages/software-factory/src/harness/isolated-realm-stack.ts | Adds optional explicit workerManagerPort; otherwise picks dynamically and passes through to worker-manager. |
| packages/software-factory/src/harness/database.ts | Makes databaseExists more resilient, adds worker-manager indexing progress reporter during template builds. |
| packages/software-factory/src/cli/cache-realm.ts | Validates cached support.json context by probing hostURL and matrixURL before reuse. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/software-factory/scripts/lib/factory-action-dispatcher.ts
Outdated
Show resolved
Hide resolved
packages/software-factory/scripts/lib/factory-action-dispatcher.ts
Outdated
Show resolved
Hide resolved
packages/software-factory/scripts/lib/factory-action-dispatcher.ts
Outdated
Show resolved
Hide resolved
9c3f80f to
92f4489
Compare
92f4489 to
970aab3
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0594305 to
8684cc3
Compare
Add factory-tool-builder.ts that builds FactoryTool[] — executable tool functions the agent calls directly via the LLM's native tool-use protocol. Each tool has a JSON Schema definition and an execute function wrapped with auth + safety middleware. Tools provided: - write_file: routes .gts/.ts → writeModuleSource, .json → writeCardSource - read_file: reads from realm via readCardSource - search_realm: wraps searchRealm() with per-realm JWT auth - update_ticket, create_knowledge: card writes to target realm - signal_done, request_clarification: control flow signals - All registered script/realm-api tools wrapped as FactoryTool delegates Also updates: - ToolExecutor.execute() accepts (toolName, toolArgs) directly - factory-tools-smoke.ts uses the new string-based call signature - one-shot-factory-go-plan.md design doc reflects the new architecture Closes CS-10566 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8684cc3 to
6bceca7
Compare
Resolves TS2345 lint error: hoist matrixAuth variable above if/else branches so both the ok and error paths can use the narrowed local. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- write_file uses writeModuleSource for ALL files (no JSON.parse routing). Card+source MIME type means the realm server accepts raw content as-is regardless of extension. Caller is responsible for file extensions. - buildFetchOptions uses resolveAuthForUrl for trailing-slash-safe token lookup - Add run_tests tool wrapping executeTestRunFromRealm with both per-realm JWT and server JWT - Update doc ToolExecutor.execute signature to include options param - Remove unused isModuleFile/MODULE_EXTENSIONS - Update tests: remove JSON routing assertions, remove invalid-JSON test for write_file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Make executeTestRun injectable via ToolBuilderConfig for testing - Add 4 tests: tool shape/parameters, full options threading (auth, serverToken, matrixAuth, testResultsModuleUrl), default module URL fallback, and target realm JWT verification Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ssion
- realm-search: fail with exitCode=1 and clear error on non-string or
invalid JSON query args instead of silently coercing to {}
- getServerSession: return explicit error when 200 OK response has no
token (empty body, non-JSON body, or missing token field)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The doc still described write_file as routing .gts/.ts to writeModuleSource and .json to writeCardSource. Updated to reflect the current implementation: all files written via writeModuleSource with card+source MIME type. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep our updated write_file description (raw content, no routing), ToolExecutor.execute options parameter, and simplified example code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Architecture shift from declarative
AgentAction[]DSL to executable tool functions:factory-tool-builder.tsthat buildsFactoryTool[]— each tool has a JSON Schema definition (for the LLM) and anexecutefunction wrapped with auth + safety middlewareToolExecutor.execute()to accept(toolName, toolArgs)directly — removes the oldAgentActionobject formexecuteRealmApito delegate torealm-operationsfunctions instead of raw HTTP callsdeleteCard(),atomicOperation(),getServerSession()torealm-operations.tsfactory-tool-executor.test.ts,.spec.ts,.integration.test.ts) to use new signaturefactory-tools-smoke.tsto use the new call signature and exercise the ToolBuilderone-shot-factory-go-plan.mddesign doc with the new architectureKey Design
write_fileroutes.gts/.ts→writeModuleSource(),.json→writeCardSource()read_file,search_realmwrap realm operations with per-realm JWT authupdate_ticket,create_knowledgewrite card source to target realmsignal_done,request_clarificationreturn control flow signalsFactoryTooldelegating toToolExecutorrealmTokensfor realm-url tools, server JWT viaserverTokenfor realm-server-url tools (realm-create, realm-auth, realm-server-session)application/vnd.card+sourceAccept header — no custom overridesTry it out
No running services needed. From
packages/software-factory/:Expected output:
Test plan
.gts/.ts→writeModuleSourcewith raw text,.json→writeCardSourcewith parsed JSONrealm-urlarg, realm-server tools get server JWT fromrealm-server-urlarg, script tools get no auth overridesignal_donereturns DONE_SIGNAL,request_clarificationreturns CLARIFICATION_SIGNAL with message(toolName, toolArgs)formpnpm factory:tools-smokepasses 31/31pnpm test:playwrightexercises realm-read, realm-search, and unregistered tool rejection against a live realm serverCloses CS-10566
🤖 Generated with Claude Code