Skip to content

POST /api/session/:id/prompt silently drops unknown keys (e.g. model) instead of rejecting them #363

Description

@shuv1337

Summary

PromptInput.Prompt (packages/schema/src/prompt-input.ts:29-34) only accepts text, files, agents, skills. A body that also carries model (or any unknown key) is accepted with HTTP 200 and the extra key is silently discarded, so callers believe they selected a model when they did not. Combined with #1 (agent model ignored) this produced turns running on an unintended free model with no error anywhere.

Repro (integration-v2 @ 4668dfc)

POST /api/session/<id>/prompt
{"text":"Reply with exactly: ok","model":{"providerID":"anthropic","modelID":"claude-sonnet-5"}}
→ 200 {"data":{"id":"msg_…"}}

The turn runs on the catalog default model; the model key is never validated or applied. (By contrast, omitting text correctly yields 400 InvalidRequestError: Missing key at ["text"].)

Expected

Either reject unknown keys on the prompt body with a 400 (strict decode), or accept model on the prompt and apply it for that turn (matching POST /api/session which does accept model, and session.switchModel).

Notes

Model.Ref uses id, not modelID, which is a second easy footgun for API users — worth a schema-level rejection so the mismatch is visible.

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