kimi-code/packages/kosong
Kimi Agent d96b4a0149
fix: fail fast on provider-filtered empty responses (#3101)
* fix: fail fast on provider-filtered empty responses

An APIEmptyResponseError carrying finishReason 'filtered' (OpenAI
content_filter, Anthropic refusal) is deterministic: replaying the same
request re-triggers the provider safety filter. Both isRetryableGenerateError
implementations (kosong, agent-core-v2) treated every empty response as
retryable, so step retry replayed the doomed request the full 10 attempts
before the filter notice surfaced. Return non-retryable for filtered empty
responses in both engines; the error already carries the provider.filtered
code, so the turn fails immediately with the existing filter notice.

* fix: skip the compaction shrink-retry for filtered empty responses

Both full-compaction loops routed every APIEmptyResponseError into the
shrink-and-continue branch before isRetryableGenerateError was consulted,
so a filtered response was retried with shrinking input instead of failing
fast. Exclude finishReason 'filtered' from the shrink branch in both
engines; it now falls through to the retryability check and throws
immediately. Add end-to-end tests (real kosong generate over a filtered
think-only stream) asserting a single attempt with the history untouched.

---------

Co-authored-by: kimi-agent-bot <kimi-agent-bot@users.noreply.github.com>
2026-08-20 11:55:26 +08:00
..
src fix: fail fast on provider-filtered empty responses (#3101) 2026-08-20 11:55:26 +08:00
test fix: fail fast on provider-filtered empty responses (#3101) 2026-08-20 11:55:26 +08:00
CHANGELOG.md ci: release packages (#1989) 2026-07-22 17:24:39 +08:00
package.json ci: release packages (#1989) 2026-07-22 17:24:39 +08:00
README.md Kimi For Coding 2026-05-22 15:54:50 +08:00
tsconfig.json Kimi For Coding 2026-05-22 15:54:50 +08:00
tsconfig.type-negative.json Kimi For Coding 2026-05-22 15:54:50 +08:00
tsdown.config.ts fix: align Anthropic-compatible model capabilities (#1746) 2026-07-16 01:31:38 +08:00
vitest.config.ts Kimi For Coding 2026-05-22 15:54:50 +08:00

@moonshot-ai/kosong

LLM abstraction layer used by Kimi Code.

Part of the Kimi Code monorepo.

See the main repository for documentation, issues, and contribution guidelines.

License

MIT