Skip to content

fix(agent-core): explain filtered provider stops#926

Open
tt-a1i wants to merge 1 commit into
MoonshotAI:mainfrom
tt-a1i:fix/provider-filtered-message
Open

fix(agent-core): explain filtered provider stops#926
tt-a1i wants to merge 1 commit into
MoonshotAI:mainfrom
tt-a1i:fix/provider-filtered-message

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Fixes #883.

  • show a short assistant message when the provider returns stopReason: "filtered"
  • emit the message before turn.ended so the UI has something visible instead of a silent stop
  • keep the existing stop reason and provider finish diagnostics unchanged
  • add a regression test for the event and conversation history behavior

Validation

  • pnpm --filter @moonshot-ai/agent-core exec vitest run test/agent/basic.test.ts
  • pnpm --filter @moonshot-ai/agent-core run test
  • pnpm --filter @moonshot-ai/agent-core run typecheck
  • pnpm exec oxlint --type-aware packages/agent-core/src/agent/turn/index.ts packages/agent-core/test/agent/basic.test.ts --quiet
  • pnpm --filter @moonshot-ai/agent-core run build
  • git diff --check

AI Assistance Disclosure

I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.

@changeset-bot

changeset-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f6f79d4

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

This PR includes changesets to release 1 package
Name Type
@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

@tt-a1i tt-a1i marked this pull request as ready for review June 20, 2026 04:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6f79d485a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +474 to +475
if (stopReason === 'filtered') {
this.appendProviderFilteredMessage(turnId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle empty filtered provider responses

When a provider reports finishReason: 'filtered' before emitting any content or tool calls, the default @moonshot-ai/kosong generate() path throws APIEmptyResponseError at packages/kosong/src/generate.ts:166 instead of returning a loop stop reason, so this new stopReason === 'filtered' branch is never reached. In that common content-filter scenario the turn still goes through the failed/error path rather than showing the intended user-facing filtered message; handle APIEmptyResponseError with finishReason === 'filtered' in the catch path or before it is converted to a failed turn.

Useful? React with 👍 / 👎.

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.

Output just stops when model runs into sensitive content without explaining this

1 participant