Skip to content

ThinkHarness shell: onChatResponse for a turn that failed before it wrote a reply - #3398

Merged
mattzcarey merged 6 commits into
mainfrom
slim/harness-score-errors-1
Nov 27, 2026
Merged

mattzcarey merged 6 commits into
mainfrom
slim/harness-score-errors-1

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

On the harness-backed Think shell, a turn that fails, or is stopped, before it writes a reply now fires onChatResponse, with an empty assistant message as Think does. Three error tests now make the turn fail through a public model error. This is group H, slice 1.

Score on the harness config: think-session.test.ts goes from 107 / 321 on main to 115 / 322, with no test newly failing. The class suite passes 322/322. Class-only rows in harness-class-only.json (#3387): this PR adds one.

On the shell: onTurnEnd used to skip onChatResponse when the turn had no message. It now reports with { id, role: "assistant", parts: [] }, as Think does; the shape was checked on Think. A turn withdrawn while it waited still reports nothing, because it never ran. Newly passing:

  • "should fire onChatResponse with error status on failure"
  • "… with aborted status on abort"
  • "should not fire duplicate response hooks when RPC onError throws"
  • "should propagate RPC in-band stream errors when onError rethrows"
  • "should return error status for in-band stream errors"
  • "returns status 'aborted' when aborted mid-stream"
  • the two below

Fixtures:

  • The new testChatWithModelError makes the model that beforeTurn gives fail after two text chunks. That's public on both configs.
  • "should handle errors and return error message", "should log errors via onChatError hook" and "should fire onChatResponse with error status on failure" use it now. They make the same assertions as before; only the cause of the failure is public.

Class-only, with successors (arch's ruling). These two test failures injected through the private _transformInferenceResult seam (_errorConfig), and they keep using testChatWithError:

  • "should persist partial assistant message on error". It keeps the private seam for now. Its successor, "keeps the partial reply of a turn whose model reports an error", and its row come in the next H slice.
  • "should recover and continue chatting after error". Successor, new in this PR: error handling › "answers the next turn after a model failure". It passes on both configs.

The second test has a row in harness-class-only.json in this PR. The first gets its row in the next H slice, with its successor.

No changeset: the shell isn't exported.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6a05359

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@3398

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@3398

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@3398

hono-agents

npm i https://pkg.pr.new/hono-agents@3398

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@3398

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@3398

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@3398

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@3398

commit: 6a05359

@agent-think

agent-think Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (46f27c8a → 6a053596, workflow run)

devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey force-pushed the slim/harness-score-errors-1 branch from 2f78b6f to 489ffa2 Compare November 27, 2026 07:00
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey merged commit a085150 into main Nov 27, 2026
18 checks passed
@mattzcarey
mattzcarey deleted the slim/harness-score-errors-1 branch November 27, 2026 07:17
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