Skip to content

fix: handle structured context overflow errors - #213

Merged
kermanx merged 1 commit into
mainfrom
xtr/context-overflow-responses
May 29, 2026
Merged

fix: handle structured context overflow errors#213
kermanx merged 1 commit into
mainfrom
xtr/context-overflow-responses

Conversation

@kermanx

@kermanx kermanx commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue; this addresses inconsistent context overflow handling for provider responses.

Problem

Context overflow detection used two different text matchers, so telemetry could classify the same provider error differently from the provider layer. OpenAI Responses stream failures also exposed structured context_length_exceeded errors as generic provider errors, which prevented the overflow recovery path from seeing the dedicated context overflow type.

What changed

  • Reused the shared kosong context overflow status matcher from agent-core telemetry classification.
  • Normalized OpenAI Responses error and response.failed events with context_length_exceeded into the dedicated context overflow provider error.
  • Added regression coverage for the shared matcher and structured Responses failure path.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Verification

  • pnpm -C packages/kosong exec vitest run test/errors.test.ts test/openai-responses.test.ts
  • pnpm -C packages/agent-core exec vitest run test/agent/turn.test.ts
  • pnpm -C packages/kosong run typecheck
  • pnpm -C packages/agent-core run typecheck
  • pnpm exec oxlint --type-aware packages/kosong/src/errors.ts packages/kosong/src/index.ts packages/kosong/src/providers/openai-responses.ts packages/kosong/test/openai-responses.test.ts packages/agent-core/src/agent/turn/index.ts packages/agent-core/test/agent/turn.test.ts

@changeset-bot

changeset-bot Bot commented May 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b47d03c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@moonshot-ai/agent-core Patch
@moonshot-ai/kimi-code Patch
@moonshot-ai/kosong Patch

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

@pkg-pr-new

pkg-pr-new Bot commented May 29, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@b47d03c
npx https://pkg.pr.new/@moonshot-ai/kimi-code@b47d03c

commit: b47d03c

@kermanx
kermanx merged commit 2388f20 into main May 29, 2026
7 checks passed
@kermanx
kermanx deleted the xtr/context-overflow-responses branch May 29, 2026 11:38
@github-actions github-actions Bot mentioned this pull request May 29, 2026
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