kimi-code/packages/agent-core/test/agent/compaction
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
..
anthropic-compliance.test.ts fix(agent-core): recover sessions bricked by orphan tool results (#1308) 2026-07-02 19:29:05 +08:00
compaction-scenarios.test.ts feat: attach trace_id to telemetry events (#1724) 2026-07-16 09:14:12 +08:00
full.test.ts fix: fail fast on provider-filtered empty responses (#3101) 2026-08-20 11:55:26 +08:00
handoff.test.ts feat(agent-core): keep head and tail of user messages during compaction (#1313) 2026-07-02 19:24:37 +08:00
micro.test.ts chore(agent-core): remove experimental micro compaction (#1317) 2026-07-02 19:50:51 +08:00
strategy.test.ts feat(agent-core): rework compaction to keep only user prompts and summary (#1214) 2026-07-01 01:17:30 +08:00