Skip to content

[feature] Emit diagnostics when codecs drop request fields, and on the stream path #1215

Open

Description

@markdavison

Problem

Several request fields are removed during translation without a TranslationDiagnostic, so
callers cannot tell that the upstream received a weaker request. #607 made the server surface
diagnostics that codecs already emit; this issue is about codecs that emit none for these
drops, and about the stream path, which has no diagnostics channel.

Reproduction on main at f60a7a22, TranslationEngine::default() and
TranslationPolicy::default(), translate_request("anthropic_messages", target, …):

{"model":"m","max_tokens":100,"top_k":5,
 "system":[{"type":"text","text":"sys","cache_control":{"type":"ephemeral"}}],
 "messages":[{"role":"user","content":[
   {"type":"text","text":"hi","cache_control":{"type":"ephemeral"}},
   {"type":"document","source":{"type":"text","media_type":"text/plain","data":"doc"},
    "citations":{"enabled":true}}]}]}
Target Dropped Diagnostics
openai_chat top_k, both cache_control markers, document citations []
openai_responses same, plus metadata when present []

TranslationEngine::translate_event returns Vec<Value> only, so losses found mid-stream
(for example citations, redacted_thinking or server-tool blocks with no target
representation) cannot be reported either.

Proposal

  1. Emit a warning diagnostic with a JSON path for each known-unrepresentable request field per
    codec pair, starting with the four above. lossy_conversion_policy: Reject would then reject
    them, as it already does for provider tools.
  2. Add a diagnostics sink to StreamTranslationState (for example a
    Vec<TranslationDiagnostic> the caller drains), filled by stream codecs when they drop or
    degrade content.

Happy to send a PR for (1) if this shape looks right.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions