POST /api/v1/sessions silently ignores create-time agent_config.model
Bug
POST /api/v1/sessions accepts an explicit agent_config.model, but the current kap-server create handler does not apply it. The session's main agent remains unbound, so a later prompt that omits model can end with model.not_configured.
This issue intentionally tracks only the create-time model field. It does not request that the general Session DTO expose live agent configuration.
Affected versions
Verified on 0.27.0, 0.28.0, 0.28.1, 0.29.0, and 0.29.1 from source tags and published npm distributions.
Reproduction
# 1. Create a session with an explicit configured model alias.
curl -X POST http://localhost:PORT/api/v1/sessions \
-H 'Content-Type: application/json' \
-d '{"metadata":{"cwd":"/some/dir"},"agent_config":{"model":"my-model-alias"}}'
# 2. Inspect the actual live agent state.
curl http://localhost:PORT/api/v1/sessions/{id}/status
# Expected: model == "my-model-alias"
# Actual: model is absent because the main agent was never bound.
# 3. Submit without repeating the model.
curl -X POST http://localhost:PORT/api/v1/sessions/{id}/prompts \
-H 'Content-Type: application/json' \
-d '{"content":[{"type":"text","text":"hi"}]}'
# The accepted turn later fails with model.not_configured ("Model not set").
Root cause
The create handler in packages/kap-server/src/routes/sessions.ts calls ISessionLifecycleService.create({ workDir }) and applies body.title, but never reads body.agent_config.
The request contract nevertheless includes the field:
packages/kap-server/src/protocol/session.ts:sessionCreateSchemaincludes optionalagent_config.packages/agent-core-v2/src/app/sessionLegacy/sessionProtocol.ts: the agent-config schema includesmodel.
The previous engine's SessionService.create forwarded input.agent_config?.model into session creation, where it bound the initial main-agent model. The current omission is therefore a port regression for this field, not a new client requirement.
Expected behavior
When agent_config.model is present on POST /sessions, the server must either:
- bind that model to the new session's main-agent profile and preserve it across resume; or
- reject the request with a validation/configuration error.
It must not accept the field and silently discard it. GET /sessions/{id}/status and a prompt submitted without a repeated model are suitable behavioral verification surfaces.
Explicitly out of scope
- Populating
GET /sessions/{id}orGET /sessions/{id}/profilewith the live model. Those Session-shaped responses intentionally projectagent_config: { model: "" }for legacy wire fidelity;/statusis the live model surface. - Defining create-time semantics for the other
agent_configfields. - Deciding whether a session created without an explicit model should eagerly bind
default_model.
Impact
REST clients that provide the model once during session creation, as the schema permits, receive a successful create response but an unusable unbound session. Downstream example: Mtrya/kimi-bridge#17.