-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
bugSomething is broken or behaving incorrectly.Something is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.Issue needs maintainer review and initial categorization.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
With a Claude model selected, send three messages:
- "hi"
- "hi 2"
- "how many times do you see that /model was run?"
Claude will answer 3, once before each message, even if the same model is selected each time.
Expected behavior
setModel should only be called when the claude model actually changes, so that the context isn't polluted with unnecessary model changing messages
Actual behavior
The following text is inserted for each user message:
<local-command-caveat>Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.</local-command-caveat>"
<command-name>/model</command-name>
<command-message>model</command-message>
<command-args>claude-model-4-6</command-args>
This pollutes the context with irrelevant info quite a bit.
Impact
Minor bug or occasional failure
Version or commit
main @ 529315b
Environment
Claude Provider
Logs or stack traces
claude jsonl session log:
{"type":"queue-operation","operation":"enqueue","timestamp":"2026-03-24T19:40:03.582Z","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9"}
{"type":"queue-operation","operation":"dequeue","timestamp":"2026-03-24T19:40:03.583Z","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9"}
{"parentUuid":null,"isSidechain":false,"promptId":"4e3f2fd3-af80-494e-a194-a0109d461e34","type":"user","message":{"role":"user","content":"<local-command-caveat>Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.</local-command-caveat>"},"isMeta":true,"uuid":"8bc63c5a-5e5a-4390-a074-8df6e6831951","timestamp":"2026-03-24T19:40:03.560Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"8bc63c5a-5e5a-4390-a074-8df6e6831951","isSidechain":false,"promptId":"4e3f2fd3-af80-494e-a194-a0109d461e34","type":"user","message":{"role":"user","content":"<command-name>/model</command-name>\n <command-message>model</command-message>\n <command-args>claude-sonnet-4-6</command-args>"},"uuid":"288bf7aa-3991-4d21-8be7-a835102fb91c","timestamp":"2026-03-24T19:40:03.560Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"288bf7aa-3991-4d21-8be7-a835102fb91c","isSidechain":false,"promptId":"4e3f2fd3-af80-494e-a194-a0109d461e34","type":"user","message":{"role":"user","content":"<local-command-stdout>Set model to claude-sonnet-4-6</local-command-stdout>"},"uuid":"b151a9a2-b105-497c-8279-11e063702638","timestamp":"2026-03-24T19:40:03.560Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"b151a9a2-b105-497c-8279-11e063702638","isSidechain":false,"promptId":"4e3f2fd3-af80-494e-a194-a0109d461e34","type":"user","message":{"role":"user","content":[{"type":"text","text":"hi"}]},"uuid":"8b59d566-cb10-493f-a6ec-a29d4003fe64","timestamp":"2026-03-24T19:40:03.598Z","permissionMode":"bypassPermissions","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"8b59d566-cb10-493f-a6ec-a29d4003fe64","isSidechain":false,"message":{"model":"claude-sonnet-4-6","id":"msg_01EpQuEZrx7Po7iCFtrAXKwa","type":"message","role":"assistant","content":[{"type":"text","text":"Hi! How can I help you today?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":3938,"cache_read_input_tokens":6212,"output_tokens":12,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":3938,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CZNUNUVLTi8RDqvmBXJVS","type":"assistant","uuid":"a1586a24-4433-4aea-b7bd-887fca53aa0b","timestamp":"2026-03-24T19:40:05.431Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"type":"queue-operation","operation":"enqueue","timestamp":"2026-03-24T19:40:09.241Z","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9"}
{"type":"queue-operation","operation":"dequeue","timestamp":"2026-03-24T19:40:09.241Z","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9"}
{"parentUuid":"a1586a24-4433-4aea-b7bd-887fca53aa0b","isSidechain":false,"promptId":"8aeb5021-908e-4b10-a973-629b86f546df","type":"user","message":{"role":"user","content":"<local-command-caveat>Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.</local-command-caveat>"},"isMeta":true,"uuid":"0a4e061b-3dc1-4dfb-90f4-caaee31a9fe8","timestamp":"2026-03-24T19:40:09.232Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"0a4e061b-3dc1-4dfb-90f4-caaee31a9fe8","isSidechain":false,"promptId":"8aeb5021-908e-4b10-a973-629b86f546df","type":"user","message":{"role":"user","content":"<command-name>/model</command-name>\n <command-message>model</command-message>\n <command-args>claude-sonnet-4-6</command-args>"},"uuid":"7d8ca9df-b9e8-43e4-b1b5-33cbce863aa6","timestamp":"2026-03-24T19:40:09.232Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"7d8ca9df-b9e8-43e4-b1b5-33cbce863aa6","isSidechain":false,"promptId":"8aeb5021-908e-4b10-a973-629b86f546df","type":"user","message":{"role":"user","content":"<local-command-stdout>Set model to claude-sonnet-4-6</local-command-stdout>"},"uuid":"cf8ebca9-62ce-4f3a-bb63-3034777f6b05","timestamp":"2026-03-24T19:40:09.232Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"cf8ebca9-62ce-4f3a-bb63-3034777f6b05","isSidechain":false,"promptId":"8aeb5021-908e-4b10-a973-629b86f546df","type":"user","message":{"role":"user","content":[{"type":"text","text":"hi 2"}]},"uuid":"8dfa3c38-3176-46aa-8c6a-13e517470b02","timestamp":"2026-03-24T19:40:09.247Z","permissionMode":"bypassPermissions","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"8dfa3c38-3176-46aa-8c6a-13e517470b02","isSidechain":false,"message":{"model":"claude-sonnet-4-6","id":"msg_016pf66jCFXgveZKmWfcmej7","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"The user said \"hi 2\". Simple greeting response.","signature":"EtcBCkYIDBgCKkDEMWjEpc73R0xGZSVmSfMyBERV1cWByLD9RyPk+EFNO6ru5M8INq27mg9imGrVKc9Hv90U2+Y+rjHlSEvb8U24EgwqhdHD7G+Z8V1FoUcaDNj7e37t1LFO4jUI6iIwCYDcCHjeGRCCktR7f8j4zLnw6dZK5gFydvpmSIexBFX8biKvqDU5YwjZhztuowpNKj/J6zU1/W05yR9LgmALyzDxkXJZHlBnE/1gbiuGLQH/O5UpHERFpdwUkCUBr3xK0BMk9VAz0jB1mJuBZ8+IoLsYAQ=="}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":143,"cache_read_input_tokens":10150,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":143},"output_tokens":0,"service_tier":"standard","inference_geo":"not_available"}},"requestId":"req_011CZNUNtavaaWBkvQjuoZ8Z","type":"assistant","uuid":"0b83e5bc-5f6b-4cbe-ba9e-c180ad4dedb2","timestamp":"2026-03-24T19:40:11.694Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"0b83e5bc-5f6b-4cbe-ba9e-c180ad4dedb2","isSidechain":false,"message":{"model":"claude-sonnet-4-6","id":"msg_016pf66jCFXgveZKmWfcmej7","type":"message","role":"assistant","content":[{"type":"text","text":"Hi again! 👋 What's on your mind?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":143,"cache_read_input_tokens":10150,"output_tokens":43,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":143,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CZNUNtavaaWBkvQjuoZ8Z","type":"assistant","uuid":"4420ddbb-6b57-45c0-8edd-46ef0d94b71a","timestamp":"2026-03-24T19:40:11.701Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"type":"queue-operation","operation":"enqueue","timestamp":"2026-03-24T19:40:27.736Z","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9"}
{"type":"queue-operation","operation":"dequeue","timestamp":"2026-03-24T19:40:27.736Z","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9"}
{"parentUuid":"4420ddbb-6b57-45c0-8edd-46ef0d94b71a","isSidechain":false,"promptId":"99c78481-28db-4330-ac8d-21b8469445e0","type":"user","message":{"role":"user","content":"<local-command-caveat>Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.</local-command-caveat>"},"isMeta":true,"uuid":"bbb8b9f4-cc88-47ba-bb79-9713e9a09235","timestamp":"2026-03-24T19:40:27.730Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"bbb8b9f4-cc88-47ba-bb79-9713e9a09235","isSidechain":false,"promptId":"99c78481-28db-4330-ac8d-21b8469445e0","type":"user","message":{"role":"user","content":"<command-name>/model</command-name>\n <command-message>model</command-message>\n <command-args>claude-sonnet-4-6</command-args>"},"uuid":"45631aab-f6e0-40fc-b2a9-ccac3a0d1d9c","timestamp":"2026-03-24T19:40:27.730Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"45631aab-f6e0-40fc-b2a9-ccac3a0d1d9c","isSidechain":false,"promptId":"99c78481-28db-4330-ac8d-21b8469445e0","type":"user","message":{"role":"user","content":"<local-command-stdout>Set model to claude-sonnet-4-6</local-command-stdout>"},"uuid":"06d3bbed-f69a-49b2-8d41-6a17faeac5de","timestamp":"2026-03-24T19:40:27.730Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"06d3bbed-f69a-49b2-8d41-6a17faeac5de","isSidechain":false,"promptId":"99c78481-28db-4330-ac8d-21b8469445e0","type":"user","message":{"role":"user","content":[{"type":"text","text":"how many times do you see that /model was run?"}]},"uuid":"e2b974e7-2a20-4538-b741-2eee7d0515b0","timestamp":"2026-03-24T19:40:27.739Z","permissionMode":"bypassPermissions","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"e2b974e7-2a20-4538-b741-2eee7d0515b0","isSidechain":false,"message":{"model":"claude-sonnet-4-6","id":"msg_019kfznEw9ncrRViSsW4Ayzo","type":"message","role":"assistant","content":[{"type":"thinking","thinking":"The user is asking about the /model command. Looking at the conversation, I can see the /model command was run 3 times (once before \"hi\", once before \"hi 2\", and once before this message). However, the caveat says these were generated by the user running local commands and I should NOT respond to these messages unless explicitly asked. The user is now explicitly asking about it, so I can respond.","signature":"ErgECkYIDBgCKkC0GyzatfrrTGdeSUDwOMzn6JijAjL8BzATTESiRKDygXTktHEngQB4KiqQq1Gzh/aGbEyD1gFYZNBExMHkXJoJEgwhlI4byYVFnSP3FzUaDB+yUhyLOBu2fKOnwSIwZcjZUdrwpPCcaBcQkbJgn00Oiu6jVRjLPTDJ/5+yYD51LIe0uuPptCrOuzHXc9uLKp8D032QsZnjclYdwHjsFii0vsxP4S65QQMG8rSjTvWXAJpLkaWhjxbaJIATuD4If2tfLAxaJgA/73tcJoO83gjtZTTmNRK7Mjov5AXNiJKOImAuGDVyNj7iPubnmp4EPXtOfG6HW0qt2OLzO5XIOKWTUv1nwovguQ3yT6nsEjI4VOtEG8YyN58l4WFyHj1LLikBr2KfREfwFgv8aierroPqRdGnZnpzbFgf7OpmJGUWHLnwRITmv6zW5OIQNqI+60GIASSKa5hPXcm/BWGKI1qSsV/kev2/HWHz62AsNtSTbn7Cvt5e/zO5QJxaR5utjYCDZRQ3jcHlrou71WboOX3BNCITERl5Q4kuqiVxu0OJn59GkwiHU3ABuXRs/4073oQXJikhR08XotJex81l4+igCgyI955jM9owS/HBqwilyxUScBvLYEmCXyib1Euywo1lT0FvBQvbdYMy/uCxIPoM07OWRYrBOoqdDmGuOYM4qpdhfTR5vDLORHs/ZrW9naQeDS3RZsTochA6N+Kzn7gD+yeveIB/sgzrv9IvyUC6HRgB"}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":183,"cache_read_input_tokens":10293,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":183},"output_tokens":6,"service_tier":"standard","inference_geo":"not_available"}},"requestId":"req_011CZNUQFfUCeMq1ePeYEmMp","type":"assistant","uuid":"418ac8d6-d701-42f1-85c6-011328fa5a4d","timestamp":"2026-03-24T19:40:30.560Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}
{"parentUuid":"418ac8d6-d701-42f1-85c6-011328fa5a4d","isSidechain":false,"message":{"model":"claude-sonnet-4-6","id":"msg_019kfznEw9ncrRViSsW4Ayzo","type":"message","role":"assistant","content":[{"type":"text","text":"I can see the `/model` command was run **3 times** — once before each of your messages (\"hi\", \"hi 2\", and this current message). Each time it set the model to `claude-sonnet-4-6`."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":183,"cache_read_input_tokens":10293,"output_tokens":158,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":183,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CZNUQFfUCeMq1ePeYEmMp","type":"assistant","uuid":"ce2d9769-3897-4715-abc8-823889de2925","timestamp":"2026-03-24T19:40:31.274Z","userType":"external","entrypoint":"sdk-ts","cwd":"/home/user","sessionId":"4583438d-5539-4d73-8785-2503d7f159b9","version":"2.1.81","gitBranch":"HEAD"}Screenshots, recordings, or supporting files
Workaround
Accept the extra tokens.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething is broken or behaving incorrectly.Something is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.Issue needs maintainer review and initial categorization.