Repository navigation
feat(voice): the call acts as the agent, over a locked tool surface (ent#535) - #2656
Conversation
…ent#535) `run_task` from a Workspace voice call went to the agent container's task endpoint: a stateless run with a 30s timeout, no thread, no memory of the conversation the person was in. In the issue's words, that is "what makes voice just chat today". A Workspace call now runs the turn through `portal_chat` — the SAME pipeline a typed message takes — into the thread the call is bound to, on the thread's own `cached_claude_session_id`. The agent has its skills, its files, its memory and its mid-work state, and the answer lands in that chat as a turn (and on the canvas if it drew). A call with no thread (VoIP, the legacy Agent Detail session) keeps the container path, because there is nothing to run it in. The split is `_is_workspace_bound`, which requires BOTH `portal_session_id` and `client_email`: a thread with no email cannot be attributed, an email with no thread has nowhere to land, and either alone would silently fall back to the container. **The spoken budget is not a cancellation.** Past `_SPOKEN_BUDGET_SECONDS` (20s) the model is told the work is still running and keeps the floor, while the turn CONTINUES and its reply lands in the chat. The old 30s `wait_for` cancelled it — throwing away work already done and paid for. The detached turn is strongly referenced so it cannot be collected mid-flight (the #1083 footgun), and it deliberately outlives the call: a turn the person asked for is worth landing whether or not they are still on the line. `_on_tool_result` fires when it lands, so a badge clears on the real event rather than on a timer. **The manifest is locked.** `services/voice_tools.py` owns the policy: resolved once at session start, `_build_live_config` builds the config FROM it, and the dispatcher refuses any name outside it before reading an argument. A per-agent declaration may only NARROW — `template.yaml` is agent-writable, so a declaration that could ADD would let an agent grant itself a capability by editing itself. Fleet tools are absent by construction: `PLATFORM_VOICE_TOOLS` is the only door a name enters through. Two defects found while building it, both fixed here: * the manifest was read as `session.tool_manifest or default`, so an agent declaring `voice.tools: []` — the strongest narrowing — fell through to the FULL platform set. The field is tri-state now: `None` is "never resolved" (→ the safe default), `frozenset()` is a decision. * `_execute_and_respond` read a nameless tool call as `run_task` (`getattr(fc, 'name', 'run_task')`), sending the model's arguments to the agent under a name nobody chose. It is refused now, and the refusal ANSWERS the call — a model that never receives a response for a call it made stops speaking. Scoped out, as decisions rather than omissions: * **the template-declared narrowing is mechanism-only.** `resolve_manifest` takes and honours a declaration, and `create_session` threads it — but nothing reads one yet, because `/api/template/info` does not expose a `voice` block. Adding it means an agent-server field plus a base-image rebuild, and a reader against a field no deployed agent returns would be a feature that reads as working and does nothing. * **the orb badge is backend-only.** The session counts in-flight turns and the landing fires `_on_tool_result`; rendering it is frontend work this PR does not do. `_execute_tool` keeps its original `(agent_name, …)` contract — the routing moved to the dispatcher, which already holds the session — so the existing container-path tests still exercise the real thing. Two panel tests move to `workspace_mode=True`: the canvas tools only exist in a workspace session, which is the combination the model could ever produce. 23 new tests, mutation-checked (a cancelling budget, a widening union, and a dropped refusal each turn the suite red). 1001 passed across the voice, canvas, portal and VoIP families. Related to Abilityai/trinity-enterprise#535 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
merge-train 2026-09-09: not on this train. The allowlist shape is right and the tests genuinely execute the dispatcher — zero The "locked" manifest is silently unlocked by the cross-worker rebuild — The Redis Reproduced with Production runs Failure scenario: an agent declares It is latent today purely because no caller passes The guard that should have caught it — Also worth folding in while it is open:
Cleared explicitly, so it is on record: the refusal is positive-membership allowlisting (correct per Invariant #13 / the #848 precedent), fires before any argument is read, and CI note: Rides the next train once the manifest round-trips. |
…on the session (ent#535) **The critical.** The Redis session blob omitted `tool_manifest`, so the cross-worker rebuild silently unlocked it: `get_session` passed nothing, `_session_manifest` read `None` as "never resolved", and the reconstruction handed the model the FULL platform default — in the `LiveConnectConfig` and in the dispatcher, with no log line, because from that worker's view nothing had ever been narrowed. Production runs `--workers 2` and the WebSocket routinely lands on a worker other than the one `/voice/start` ran on, so this is the normal path, not an edge case. The block comment directly above that dict says "EVERY field a reconstructed session decides on must be here"; this PR added a decision field and did not. It is stored as `sorted(...)`/`null` — `json.dumps` cannot serialize a set, so writing the frozenset raw would raise inside the try and lose the whole blob — and read back by `_manifest_from_meta`, which maps three inputs onto two answers: absent or `null` → unresolved (the pre-ent#535 default, and the mid-deploy case); a list, INCLUDING `[]` → a decision; anything else → unresolved rather than a crash in the audio loop. Collapsing `null` and `[]` would reintroduce the exact inversion this PR fixed. `test_create_session_writes_redis` asserted three named keys and never round-trip completeness, which is why this shipped green. It is now a SUBSET relation over the session's own dataclass fields, with the deliberately-unpersisted ones listed by reason, so a field added tomorrow fails the guard instead of shipping unpersisted. **Also folded in, all from the review:** * `_portal_turn` had 15 unreachable lines below its `return`, copy-pasted from `_execute_tool` and referencing names not in that scope. Removed, with an AST guard so nothing lands after that return again. * The empty-prompt guard is back on the chat path. `portal_chat` calls `_persist_user_turn` unconditionally, so a blank `run_task` durably wrote an empty user row into the person's Workspace thread and dispatched a real, cost-tracked execution; `required=["prompt"]` makes that unlikely, not impossible. Stripped rather than falsy, and worded identically on both paths. * `include_owned=True` is no longer a constant at the turn site. It travels on the session as `is_platform` (default False), written by `start_workspace_voice` — the function that refuses a non-platform caller, so the gate that authorizes the wider roster read is the one that records it. Sound today because that function is the only writer of `portal_session_id` + `client_email`; a future path setting both would otherwise widen `agent_on_roster` with no change at that line (Invariant #8). `canvas_audience` already travels for exactly this reason. * `docs/memory/requirements/runtimes.md` §29.7 (VOICE-007) rewritten — it still claimed a 30s timeout and `_execute_and_respond()` → `POST /chat`, both false for the Workspace path since this PR. AC 7 said it had been; only the feature-flow had. Removing the persisted field reds three of the new tests; verified by deleting it and re-running. 848 passed across every voice / portal test in the suite. Related to Abilityai/trinity-enterprise#535 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01RSjVEjay9ztC1oDXXkh9uN
|
All of it in The manifest round-trips. Stored as
The rest, all folded in:
On the CI note: agreed, |
|
Re-review after the fixes. Clean from me. Re-verified the two things most likely to have been half-done:
The round-trip-completeness guard is the part worth keeping beyond this PR: asserting three named keys is what let a decision field ship unpersisted, and a subset relation over the dataclass fields fails on the next one too. |
|
Deeper self re-review. No further defect. Three things checked properly this time.
The guard worth keeping past this PR is the round-trip-completeness one: |
|
merge-train 2026-09-10: on this train. One thing that patch does not buy, so flagging it explicitly: Verified, not assumed. Your tests genuinely execute the changed paths — the manifest lock, the dispatcher refusal, the config build, and a real Redis round-trip across workers ( Credential check specific to this path: all four new log lines carry agent name / tool name / a client-safe truncated detail. No token, key, or Findings left for you — none blocking:
One line would convert the last text-only assertion into execution: |
The bug this closes
run_taskfrom a Workspace voice call went to the agent container's task endpoint: a stateless run with a 30s timeout, no thread, no memory of the conversation the person is in. In the issue's words, that is "what makes voice just chat today" — and it was the one objection in #440's implementation note still standing.What changes
A Workspace call runs the turn as the agent, in its own thread.
_run_task_in_chat→client_portal.service.portal_chat→ the resumable-turn engine → the thread'scached_claude_session_id. The same pipeline a typed message takes, so the agent has its skills, files, memory and mid-work state, and the answer lands in that chat as a turn (and on the canvas if it drew).A call with no thread — VoIP, the legacy Agent Detail session — keeps the container path, because there is nothing to run it in. The split is
_is_workspace_bound, requiring bothportal_session_idandclient_email: a thread with no email cannot be attributed, an email with no thread has nowhere to land, and either alone would silently fall back to the container.The spoken budget is not a cancellation. Past
_SPOKEN_BUDGET_SECONDS(20s) the model is told the work is still running and keeps the floor, while the turn continues and its reply lands in the chat. The old 30swait_forcancelled it — throwing away work already done and paid for. The detached turn is strongly referenced so it cannot be collected mid-flight (the #1083 footgun), and it deliberately outlives the call: a turn the person asked for is worth landing whether or not they are still on the line.The manifest is locked.
services/voice_tools.pyowns the policy — resolved once at session start,_build_live_configbuilds the config from it, and the dispatcher refuses any name outside it before reading an argument (the Brain Orb/actionshape). A per-agent declaration may only narrow:template.yamlis agent-writable, so one that could ADD would let an agent grant itself a capability by editing itself.Two defects found while building it
session.tool_manifest or default, so an agent declaringvoice.tools: []— the strongest possible narrowing — fell through to the full platform set. The field is tri-state now:Noneis "never resolved" (→ the safe default),frozenset()is a decision.run_task(getattr(fc, 'name', 'run_task')), sending the model's arguments to the agent under a name nobody chose. Refused now — and the refusal answers the call, because a model that never receives a response for a call it made stops speaking.Scoped out — decisions, not omissions
resolve_manifesttakes and honours a declaration andcreate_sessionthreads it, but nothing reads one yet:/api/template/infodoes not expose avoiceblock. Wiring it means an agent-server field plus a base-image rebuild, and a reader against a field no deployed agent returns would be a feature that reads as working and does nothing. The wiring point is one call away._on_tool_result; rendering it is frontend work this PR does not do.Acceptance criteria
run_taskruns as the agent in the Workspace chat's resumed session; result lands in that chatPLATFORM_VOICE_TOOLSbeing the only doorvoice_tool_call, Workspace principal, via the shared/ws/voicedriver). Container-path tasks get a transcript note; a Workspace task does not, because the turn is a row in the thread — a better record, and a note would read as a second turn beside the real onerun_taskis never told to narrate itvoice-chat.mdVOICE-007 rewritten ✅; closingabilityai/trinity#711/#670left to the issue ownerCompatibility
_execute_toolkeeps its original(agent_name, …)contract — the routing moved to the dispatcher, which already holds the session — so the existing container-path tests still exercise the real thing. Two panel tests move toworkspace_mode=True: the canvas tools only exist in a workspace session, which is the only combination the model could ever produce.Verification
Mutation-checked — each turns the suite red: a budget that cancels the turn, a union instead of an intersection in
resolve_manifest, and a dropped dispatcher refusal.Fixes abilityai/trinity-enterprise#535
🤖 Generated with Claude Code