Fix operator chat: CLI never sent agentId, breaking th chat + MCP ask_business on every org - #507
Open
brentrager wants to merge 2 commits into
Open
Fix operator chat: CLI never sent agentId, breaking th chat + MCP ask_business on every org#507brentrager wants to merge 2 commits into
brentrager wants to merge 2 commits into
Conversation
…sion th api smooth-operator chat and MCP ask_business both failed on every org with VALIDATION_ERROR: missing 'agentId'. Both route through operator_turn, so one fix covers both. agentId is required by the SEP Request schema; smooth-operator-server used to fabricate one for an absent field, and th-68897a moved that check to the boundary. This client relied on the fabrication. The dashboard did not, which is why the UI kept working. Send a fresh uuid, matching the dashboard's agentSlug ?? crypto.randomUUID(). It is a correlation id, not an agents.id: copilot-ws runs its storage adapter with with_builtin_session_agent(), which ignores the caller's agent id and binds the session to the org's built-in Smooth Operator row. No agent is picked and no behaviour changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The negative control found it: with agentId set to " " the resume test still passed, because it checked is_empty() where the server checks trim().is_empty(). A whitespace agentId would have shipped past that assertion while still being rejected on the wire. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 26f500a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
th api smooth-operator chatand the MCPask_businesstool both failed before the turn ever started:This was not a master-org config gap and not one org. Reproduced on four unrelated orgs — Smoo AI (master), Chakra AI Solutions, HeyPage, Smoo AI Marketing — all identical. Every customer using either operator entry point was broken.
Root cause — the caller, not the server, and not a missing default agent
agentIdis required by the SEP Request schema, butsmooth-operator-serverused to fabricate a UUID when the field was absent. th-68897a moved that check to the boundary where it belongs —handle_create_sessionnow rejects absent-or-blank rather than silently minting an id or storing NULL. That server change is correct.This hand-rolled WS client in
smooth_operator_ws.rswas one of the callers relying on the old fabrication, so it began failing the moment the new server rolled out. The dashboard kept working because it always sent one.There is no "default operator agent" to wire up, and no org config is missing.
Fix
The create frame now carries a fresh uuid — exactly what the working dashboard client sends (
agentId: agentSlug ?? crypto.randomUUID()insmooth-operator-chat.tsx).It picks no agent, and changes no behaviour. It is a correlation id, not an
agents.id: copilot-ws — the pod behindsmooth-operator.smoo.ai— runs its storage adapter withwith_builtin_session_agent(), which ignores the caller's agent id and binds the session to the org's built-in "Smooth Operator" row. That is precisely why the dashboard's random uuid works.Every other
create_conversation_sessioncaller in this repo already sendsuuid::Uuid::new_v4()—smooth-daemon/src/scheduler.rs,smooth-code/src/client.rs,smooth-bench,smooth-web/operator.ts. This one was the lone straggler; the fix makes it consistent.One fix covers both reported entry points:
th … chatand MCPask_businessboth route throughoperator_turn.Verification
Built the binary and ran it against production:
Reply with exactly: OK→OK✅ (wasVALIDATION_ERROR)OK✅conversation_idreturned, prior turn recalled ✅Gates:
cargo fmt --checkclean;cargo clippy(CI's exact command — the workflow deliberately omits-D warningsso advisory pedantic lints are not weaponized) passes with zero warnings from the changed file; 7/7 tests pass.Tests + negative controls
Frame construction moved into a pure
create_frameso the regression is testable. Each assertion was broken and confirmed to fail:agentId(the original bug)agentId=" "(blank)agentId="not-a-uuid"agentIdconversationIdon resumeControl 2 earned its keep: the resume test passed on a whitespace agentId because it checked
is_empty()where the server checkstrim().is_empty(). Tightened in the second commit, after which control 2 fails all three as it should.🤖 Generated with Claude Code