feat(interface): preserve exact recursive agent profiles - #104
Conversation
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved drewstone PR — dcfa8ee8
This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: drewstone_author · 2026-07-30T19:28:15Z
tangletools
left a comment
There was a problem hiding this comment.
🟡 Value Audit — sound-with-nits
| Verdict | sound-with-nits |
| Concerns | 1 (1 weak-concern) |
| Heuristic | 0.0s |
| Duplication | 0.0s |
| Interrogation | 140.1s (2 bridge agents) |
| Total | 140.1s |
💰 Value — sound-with-nits
Makes the cli-bridge forward profiles/sessions intact and exports a canonical profile JSON Schema — all coherent and in-grain, with one minor near-duplicate helper.
- What it does: Four coupled changes: (1) cli-bridge now requires an inline AgentProfile, freezes it via the existing snapshotAgentProfile, and forwards it unchanged in the agent_profile field plus reasoning effort, instead of copying the system prompt into a system message; (2) cli-bridge implements dispatch()/session() returning durable, resumable AgentSession handles (detach + cursor replay); (3) exports agent
- Goals it achieves: Recursive agents that author child profiles get the real, validated profile shape handed to providers verbatim — no field invention (the JSON Schema), no authority duplication into messages (single source = the profile), and durable/resumable sessions so a parent can dispatch and reattach. It also fixes a latent doc/code contradiction: the docs claimed harness was not part of identity while canoni
- Assessment: Sound and in the grain. The cli-bridge dispatch/session work catches up to an interface (environment-provider.ts:273-292) that agent-provider-tangle already implements — extending, not inventing. agentProfileJsonSchema is generated from the single canonical validator rather than hand-maintained (avoids drift), and stripping the ^u(?:[0-9a-f]{4})*$ propertyNames is correct because that pattern is t
- Better / existing approach: Searched for an existing JSON-schema emitter (only z.toJSONSchema here, no prior art), an existing coordination tool consuming this schema (none in-repo — it's a published library export awaiting consumers, acceptable for an SDK package), and existing session-handle implementations. None should be reused over the chosen design. One near-duplicate helper exists (see findings).
- Model: opencode/zai-coding-plan/glm-5.2
- Bridge attempts: 2
- Bridge warning: opencode/kimi-for-coding/k2p7: bridge stream ended without value-audit content
🎯 Usefulness — sound
A coherent change that conforms to existing interface contracts (durable sessions already implemented by agent-provider-tangle), preserves exact profile authority at intake via an existing snapshot primitive, and exposes the canonical profile JSON Schema derived from the validator rather than duplic
- Integration: All new behavior wires into established, reachable surface. The cli-bridge's dispatch()/session() implement the optional methods already declared on AgentEnvironment (environment-provider.ts:291-292), already implemented by agent-provider-tangle (index.ts:227,238), and already validated by agent-provider-testkit (index.ts:104-111). snapshotAgentProfile is an existing primitive now consumed at the
- Fit with existing patterns: Fits the codebase grain precisely. The durable-session implementation mirrors agent-provider-tangle's shape (polymorphism, not duplication). The JSON Schema is generated from the canonical Zod validator with narrowly-targeted removal of Zod's internal record-key encoding artifacts (the ^u(?:[0-9a-f]{4})*$ pattern from ownPropertyRecordSchema) and the root $schema, rather than hand-maintaining a se
- Real-world viability: Tests cover well beyond the happy path: profile immutability across intake (caller mutation of prompt/model rejected), named-profile rejection before any network use, exact forwarding of agent_profile + reasoning effort, durable dispatch with verified HTTP reader detachment, cursor-based replay, usage-preserving terminal results, session continuation, terminal-confirmed cancellation, request-diges
- Model: opencode/zai-coding-plan/glm-5.2
- Bridge attempts: 1
💰 Value Audit
🟡 Local addTokenUsage near-duplicates agent-core's shared helper [duplication] ``
cli-bridge adds its own addTokenUsage (index.ts:666-704) that accumulates the full TokenUsage shape (inputTokens, outputTokens, plus totalTokens, cacheRead/Creation, reasoningTokens, cost). A shared addTokenUsage already exists at packages/agent-core/src/telemetry/token-usage.ts:135 and is exported from agent-core — but it only sums inputTokens+outputTokens, so it is too thin to reuse here as-is. Two options for a reviewer to weigh: extend the shared helper to accumulate the full TokenUsageCount
What this audit checks
It judges the change on its merits — not whether it was tasked out in an issue. Unticketed, fast-moving work is fine; the question is whether the change is good and whether a better or existing approach should be used instead.
| Pass | What it asks |
|---|---|
| Heuristic | Vague title? Whitespace-only or cruft-bearing diff? (content signals only) |
| Duplication | Do added function/class names already exist elsewhere in the repo? |
| Value Audit | What does it do? What goal does it achieve? Is it good? Better architecture or already-exists? |
| Usefulness Audit | Does it integrate and fit? Will it hold up in real use and actually get used? |
Findings are concerns, not blocks — the human reviewer decides what to do with them.
✅ No Blockers —
|
tangletools
left a comment
There was a problem hiding this comment.
✅ Approved — 8 non-blocking findings — dcfa8ee8
Full multi-shot audit completed 8/8 planned shots over 15 changed files. Global verifier still owns final merge decision.
Full immutable report for this review: trace
Summary comment for this run: full summary
tangletools · 2026-07-30T19:42:00Z · immutable trace
What changed
agentProfileJsonSchemafrom the canonical Zod input contract so model-authored child profiles receive the real shapeWhy
Recursive agents must author complete child profiles, and provider adapters must preserve those profiles and sessions without inventing policy. The old coordination tool described
profileonly as an object, so models invented invalid fields.Verification
z.fromJSONSchemaand the canonical validator