Skip to content

refactor: share LLM retry classification - #92

Merged
kermanx merged 1 commit into
mainfrom
xtr/share-llm-retry-classification
May 27, 2026
Merged

refactor: share LLM retry classification#92
kermanx merged 1 commit into
mainfrom
xtr/share-llm-retry-classification

Conversation

@kermanx

@kermanx kermanx commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue. This PR follows up on consolidating duplicate retry classification used by regular turns and compaction.

Problem

Regular turn generation and compaction used equivalent but separate checks for retryable LLM failures. Keeping those checks in separate places makes it easier for retry behavior to drift as provider error handling evolves.

What changed

  • Added a shared retry classification helper in the LLM abstraction layer for transient generation failures.
  • Updated compaction retry handling and the Kosong-backed loop adapter to use the shared helper.
  • Moved Kosong LLM construction behind the agent so turn flow no longer duplicates provider and completion budget wiring.
  • Preserved the loop-facing finish reason contract by translating missing provider diagnostics to omitted optional fields.
  • Added focused coverage for retryable and non-retryable provider errors.
  • Added a patch changeset for the affected packages and CLI bundle.

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 --filter @moonshot-ai/agent-core typecheck
  • pnpm --filter @moonshot-ai/kosong typecheck
  • pnpm exec vitest run packages/kosong/test/errors.test.ts packages/agent-core/test/agent/turn.test.ts packages/agent-core/test/agent/compaction.test.ts packages/agent-core/test/agent/kosong-llm.test.ts

@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0119c64

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/kosong Patch
@moonshot-ai/kimi-code 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

@kermanx
kermanx merged commit 4e458d6 into main May 27, 2026
5 checks passed
@kermanx
kermanx deleted the xtr/share-llm-retry-classification branch May 27, 2026 03:20
@github-actions github-actions Bot mentioned this pull request May 27, 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