Skip to content

fix(adapters): treat non-normal model finish reasons as failed turns - #131

Open
omkarjainak wants to merge 1 commit into
systemind-team:mainfrom
omkarjainak:fix/126-model-finish-reason-and-deepseek-turn-end
Open

omkarjainak wants to merge 1 commit into
systemind-team:mainfrom
omkarjainak:fix/126-model-finish-reason-and-deepseek-turn-end

Conversation

@omkarjainak

@omkarjainak omkarjainak commented Nov 26, 2026 •

Copy link
Copy Markdown

Summary

Fixes #126. Model replies stopped by content_filter or a provider error are no longer graded as successful turns with empty or partial text. The DeepSeek session-event reader also no longer completes turn/end kinds it does not recognise.

Changes

StandardTurnDriver

  • StandardTurnDriver.next now fails the turn when the provider stops generation for any reason other than a normal ending (stop/tool_calls) or the output token ceiling (length).
  • A content_filter finish reason becomes model_output_filtered; other reasons become model_stopped_<reason>.

DeepSeek session-event protocol

  • deepseekProtocol.interpret no longer treats an unknown turn/end kind as a completed turn.
  • Only completed completes; any other kind fails with the reason's own code/message when present, otherwise turnEndCode(kind).

Rationale

A finish reason that is neither a normal ending nor a length cut means the provider stopped generation for its own reason. Such a reply is not a decision the model finished making, so it must not be graded as a completed turn. The DeepSeek protocol change keeps the session-event reader consistent with the headless reader.

Testing

  • pnpm check
  • pnpm typecheck
  • pnpm vitest run packages/adapters/src/model/model.test.ts packages/adapters/src/adapters.test.ts (123 tests)
  • pnpm format:check
  • git diff --check
  • Permission-denied paths are covered
  • Protocol compatibility is documented

Security

  • New capabilities deny by default
  • Tool discovery and invocation enforce the same grant
  • No credentials, private context, or evaluator data cross boundaries

Compatibility

  • No breaking contract change
  • Breaking contract change is documented in an ADR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant