Skip to content

Show draft failures with a consumer sentence and quotable refId - #609

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-6749-agent-create-draft-failure-shows-something-went-wrong-with
Sep 4, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-6749-agent-create-draft-failure-shows-something-went-wrong-with

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Fixes CL-6749

A failed agent-create draft was answering { code, message } from a hand-wired hub route. The client only accepts { userMessage, refId }, so the panel showed a generic 422 with nothing to quote.

  • Hub mounts createAgentDefinitionDraftRoutes so 422 uses makeErrorEnvelope
  • Drafting failures go through reportError so the log and envelope share a refId
  • ApiQueryError carries refId; postJSON uses parseErrorEnvelope
  • The create-agent panel renders the consumer sentence plus Reference: <refId>

A failed Myra draft must answer the canonical envelope, keep that
userMessage and refId on the client, and show both in the panel —
never a generic 422 with no quotable id.
…749)

The hub was answering drafting_failed as {code, message}, so the
client could not parse the envelope and the panel showed a generic
422 with no refId. Mount the package draft routes, report the
failure through reportError, and thread that same refId through
ApiQueryError into the panel.
@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Self-review

Verdict: the change is correct and well-tested — hub now serves the package's createAgentDefinitionDraftRoutes (canonical {code, userMessage, refId} envelope via reportError), and the client/panel surface the consumer sentence plus a quotable refId. No defects found; nothing needed fixing.

  • Envelope plumbing (makeErrorEnvelope/reportError/parseErrorEnvelope, ApiQueryError.refId) — DISMISSED: checked signatures end-to-end, all call sites and the new optional constructor param are consistent; no exactOptionalPropertyTypes hazard.
  • Hub route de-duplication (hand-wired 422 body removed, createAgentDefinitionDraftRoutes mounted instead) — DISMISSED: verified no dangling imports/usages of the removed error classes or the old agentDefinitionDraftingInFlightPrincipals set remain in apps/hub/src/index.ts.
  • No bare catch {} / no as T on untrusted input / no fallback path left beside the new one — DISMISSED: checked, none present.

Targeted tests run (all pass):

  • apps/web: bun test test/agents-api.test.ts test/create-agent-panel.test.tsx — 27 pass
  • packages/agent-directory: bun test test/agent-definition-draft-routes.test.ts — 3 pass
  • apps/hub: bun test src/draft-route-envelope.test.ts — 1 pass

@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

CL-6749

@TheGreatAxios
TheGreatAxios merged commit 7ecfc50 into main Sep 4, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant