II.
Page JSON
Structured · livepage:docs-adapters-babysitter-integrations-effect-resolution
Effect Resolution Pipeline Changes json
Inspect the normalized record payload exactly as the atlas UI reads it.
{
"id": "page:docs-adapters-babysitter-integrations-effect-resolution",
"_kind": "Page",
"_file": "wiki/docs/adapters-babysitter-integrations/effect-resolution.md",
"_cluster": "wiki",
"attributes": {
"nodeKind": "Page",
"sourcePath": "docs/adapters-babysitter-integrations/effect-resolution.md",
"sourceKind": "repo-docs",
"title": "Effect Resolution Pipeline Changes",
"displayName": "Effect Resolution Pipeline Changes",
"slug": "docs/adapters-babysitter-integrations/effect-resolution",
"articlePath": "wiki/docs/adapters-babysitter-integrations/effect-resolution.md",
"article": "\n# Effect Resolution Pipeline Changes\n\n## Summary\n\nWhen a process dispatches an `agent` task with `external: true`, the effect resolution pipeline must route through adapters instead of the internal agent-core session. Most of the infrastructure already exists in agent-platform's adapterBridge.\n\n## Current Pipeline\n\n```\nProcess calls ctx.task(externalTask)\n → SDK throws EffectRequestedError (journaled)\n → orchestrateIteration returns status=\"waiting\"\n → run:iterate returns nextActions with the effect\n → Orchestrator resolves effect:\n CLI path: resolveAndPostEffect() in orchestration/index.ts\n Internal path: resolveEffect() in orchestration/effects.ts → invokePromptEffect()\n → Result posted back via task:post\n → Next iteration: process resumes with result\n```\n\n## Changes Needed\n\n### 1. Effect Kind Detection\n\nIn `packages/genty/platform/src/harness/internal/createRun/orchestration/effects.ts`:\n\n```typescript\n// In resolveEffect(), add external agent detection:\nif (action.kind === \"agent\" && action.taskDef?.agent?.external) {\n return resolveExternalAgentEffect(action, args);\n}\n```\n\n### 2. New: `resolveExternalAgentEffect()`\n\n```typescript\n// packages/genty/platform/src/harness/internal/createRun/orchestration/externalAgentEffect.ts\n\nasync function resolveExternalAgentEffect(\n action: EffectAction,\n args: ResolveEffectArgs,\n): Promise<EffectResult> {\n const agentDef = action.taskDef?.agent as AgentTaskOptions;\n const adapter = agentDef.adapter;\n const prompt = typeof agentDef.prompt === \"string\"\n ? agentDef.prompt\n : agentDef.prompt?.instructions?.join(\"\\n\") ?? action.taskDef?.title ?? \"\";\n\n // Check adapters availability\n const adapterClient = await getAmuxClient();\n if (!adapterClient) {\n if (agentDef.fallbackToInternal) {\n process.stderr.write(`[babysitter] adapters not available, falling back to internal for ${adapter}\\n`);\n return resolveInternalAgentEffect(action, args);\n }\n return { status: \"error\", error: `adapters not available — cannot dispatch to ${adapter}` };\n }\n\n // Dispatch via adapterBridge (already exists)\n const result = await invokeViaAgentMux(adapterClient, adapter, {\n prompt,\n model: agentDef.model ?? args.model,\n workspace: args.workspace,\n timeout: agentDef.timeout ?? 300_000,\n approvalMode: agentDef.approvalMode ?? \"yolo\",\n maxTurns: agentDef.maxTurns ?? 10,\n nonInteractive: true,\n });\n\n // Journal cost event\n if (result.totalCost > 0) {\n await appendEvent({\n runDir: args.runDir,\n eventType: \"COST\",\n event: {\n source: `external-agent:${adapter}`,\n cost: result.totalCost,\n effectId: action.effectId,\n },\n });\n }\n\n return {\n status: result.success ? \"ok\" : \"error\",\n value: result.output ?? result.lastMessage,\n error: result.success ? undefined : result.lastMessage,\n };\n}\n```\n\n### 3. CLI Orchestration Path\n\nIn `packages/genty/platform/src/harness/internal/createRun/orchestration/index.ts`, `resolveAndPostEffect()`:\n\n```typescript\nif (action.kind === \"agent\" && action.taskDef?.agent?.external) {\n // Route through adapters instead of internal agent-core session\n const agentDef = action.taskDef.agent;\n const adapter = agentDef.adapter ?? agentDef.name;\n const prompt = typeof agentDef.prompt === \"string\" ? agentDef.prompt : /* ... */;\n\n // Use adapters launch CLI\n const launchResult = execFileSync(\"adapters\", [\n \"launch\", adapter, agentDef.provider ?? \"foundry\",\n \"--model\", agentDef.model ?? model ?? \"gpt-5.5\",\n \"--prompt\", prompt,\n \"--non-interactive\",\n \"--json\",\n \"--max-turns\", String(agentDef.maxTurns ?? 10),\n ], { cwd: workspace, encoding: \"utf8\", timeout: agentDef.timeout ?? 300_000 });\n\n value = JSON.stringify(launchResult);\n}\n```\n\n## Files to Create/Modify\n\n### New Files\n- `packages/genty/platform/src/harness/internal/createRun/orchestration/externalAgentEffect.ts`\n- `packages/genty/platform/src/harness/internal/createRun/orchestration/__tests__/externalAgentEffect.test.ts`\n\n### Modified Files\n- `packages/genty/platform/src/harness/internal/createRun/orchestration/effects.ts` — add external agent routing\n- `packages/genty/platform/src/harness/internal/createRun/orchestration/index.ts` — add external agent handling in CLI path\n- `packages/genty/platform/src/harness/adapters/adapterBridge.ts` — may need minor adjustments for SDK-driven dispatch\n\n## Existing Infrastructure Reused\n\nThe adapterBridge in agent-platform already handles:\n- Harness → adapter name mapping (`adapterHarnessMap.ts`)\n- Adapters client lifecycle (`adapterClientFactory.ts`)\n- Event streaming and mapping (`adapterEventMapper.ts`)\n- Cost tracking from adapters events\n- Session ID management\n\nThis means ~80% of the effect resolution code is already written. The new code is primarily routing logic to detect external tasks and call the existing bridge.\n\n## Error Handling\n\n| Scenario | Behavior |\n|----------|----------|\n| adapters not installed | If `fallbackToInternal: true`, use agent-core. Otherwise, return error result. |\n| Adapter not installed | Return error with message: \"adapter X not installed. Run `adapters install X`\" |\n| Adapter not authenticated | Return error with message: \"adapter X not authenticated. Run `adapters auth X`\" |\n| Agent times out | Return error with timeout details. Partial output included if available. |\n| Agent crashes | Return error with stderr. Exit code included. |\n",
"documents": []
},
"outgoingEdges": [],
"incomingEdges": [
{
"from": "page:docs-adapters-babysitter-integrations",
"to": "page:docs-adapters-babysitter-integrations-effect-resolution",
"kind": "contains_page"
}
]
}