fix: add parentAgentId to stored agent record schema

- Added `parentAgentId` field to `STORED_AGENT_SCHEMA` in agent-registry.ts
- Updated `toStoredAgentRecord()` in agent-projections.ts to include parentAgentId
- This ensures parentAgentId is persisted to agents.json for parent/child hierarchy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2025-12-21 17:47:31 +00:00
parent 2d147f9a93
commit 2e8444eaac
3 changed files with 4 additions and 1 deletions

View File

@@ -52,6 +52,7 @@ export function toStoredAgentRecord(
attentionTimestamp: agent.attention.requiresAttention
? agent.attention.attentionTimestamp.toISOString()
: null,
parentAgentId: agent.parentAgentId ?? null,
} satisfies StoredAgentRecord;
}

View File

@@ -53,6 +53,7 @@ const STORED_AGENT_SCHEMA = z.object({
requiresAttention: z.boolean().optional(),
attentionReason: z.enum(["finished", "error", "permission"]).nullable().optional(),
attentionTimestamp: z.string().nullable().optional(),
parentAgentId: z.string().nullable().optional(),
});
export type SerializableAgentConfig = Pick<

View File

@@ -364,12 +364,13 @@ Files requiring modification:
- Click child agent in menu, verify navigation works
- **Done (2025-12-21 17:45)**: PARTIAL PASS - MCP header injection IS working correctly. The `X-Caller-Agent-Id` header is being sent by parent agents and received by the MCP server. The `callerAgentId` is correctly used as `parentAgentId` when creating child agents. HOWEVER, discovered a bug: `parentAgentId` is stored in `persistence.metadata` but NOT at the top-level of the stored agent record. The `toStoredAgentRecord()` function in `agent-projections.ts` and the `STORED_AGENT_SCHEMA` in `agent-registry.ts` are missing `parentAgentId`. Fix task added below.
- [ ] **Fix**: Add parentAgentId to stored agent record schema.
- [x] **Fix**: Add parentAgentId to stored agent record schema.
- Add `parentAgentId` to `STORED_AGENT_SCHEMA` in `agent-registry.ts`
- Add `parentAgentId` to `toStoredAgentRecord()` output in `agent-projections.ts`
- Read `parentAgentId` from `agent.parentAgentId` (which is on `ManagedAgentBase`)
- Run typecheck after changes.
- **Done (2025-12-21 17:52)**: Added `parentAgentId: z.string().nullable().optional()` to `STORED_AGENT_SCHEMA` in `agent-registry.ts:56`. Added `parentAgentId: agent.parentAgentId ?? null` to `toStoredAgentRecord()` output in `agent-projections.ts:55`. Typecheck passes.
- [ ] **Test**: Re-test parent/child hierarchy after storage fix.