[BUG] Resume Conversation Forgets Non-Interactive Mode Messages
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [x] Other: Claude Code
- Claude CLI version: 1.0.60 (Claude Code)
- Operating System: macOS 15,5
- Terminal: Terminal App
Bug Description
Resume conversation forgets all messages that were exchanged in non-interactive mode
Steps to Reproduce
- Send a message in non-interactive mode e.g.:
claude -p "Please tell me what 1 X 1 is (1)?" --output-format json | jq -r '.session_id' > session.txt; cat session.txt
- Try resuming that session a first time e.g.:
claude -p --resume "$(cat session.txt)" "What questions, in order, have I asked in this session (2)?"
- Try resuming that session a second time (or any number of times): e.g.
claude -p --resume "$(cat session.txt)" "What questions, in order, have I asked in this session (3)?"
Expected Behavior
I would expect that all 3 messages in the conversation were remembered, and so Claude would reply:
1. What is 1 X 1 (1)?
2. What questions, in order, have I asked in this session (2)?
3. What questions, in order, have I asked in this session (3)?
Actual Behavior
Claude forgets the second message and only knows about the first message and the current message, and so replies:
1. What is 1 X 1 (1)?
2. What questions, in order, have I asked in this session (3)?
Additional Context
It's possible to use --continue as a partial workaround for this because you can then continue the current session. But as you can see there is a similar problem in that if you try to resume the session, it forgets all the messages, which you can see in the last interaction here:
stevepersonal@Steves-MacBook-Pro tmp % claude -p "Please tell me what 1 X 1 is (1)?" --output-format json | jq -r '.session_id' > session.txt; cat session.txt
02f4d073-a7e9-4ff2-a61f-8bc9c2f24246
stevepersonal@Steves-MacBook-Pro tmp %
stevepersonal@Steves-MacBook-Pro tmp % claude -p --continue "What questions, in order, have I asked in this session (2)?"
1. Please tell me what 1 X 1 is (1)?
2. What questions, in order, have I asked in this session (2)?
stevepersonal@Steves-MacBook-Pro tmp % claude -p --continue "What questions, in order, have I asked in this session (3)?"
1. Please tell me what 1 X 1 is (1)?
2. What questions, in order, have I asked in this session (2)?
3. What questions, in order, have I asked in this session (3)?
stevepersonal@Steves-MacBook-Pro tmp % claude -p --continue "What questions, in order, have I asked in this session (4)?"
1. Please tell me what 1 X 1 is (1)?
2. What questions, in order, have I asked in this session (2)?
3. What questions, in order, have I asked in this session (3)?
4. What questions, in order, have I asked in this session (4)?
stevepersonal@Steves-MacBook-Pro tmp % claude -p --continue "What questions, in order, have I asked in this session (5)?"
1. Please tell me what 1 X 1 is (1)?
2. What questions, in order, have I asked in this session (2)?
3. What questions, in order, have I asked in this session (3)?
4. What questions, in order, have I asked in this session (4)?
5. What questions, in order, have I asked in this session (5)?
stevepersonal@Steves-MacBook-Pro tmp % claude -p --resume "$(cat session.txt)" "What questions, in order, have I asked in this session (6)?"
1. What is 1 X 1 (1)?
2. What questions, in order, have I asked in this session (6)?
stevepersonal@Steves-MacBook-Pro tmp %
UPDATE: I've discovered that the --continue option actually creates a new session id for each non-interactive interaction, which may explain this behaviour. This is very confusing and most people are going to get lost when trying to navigate this:
stevepersonal@Steves-MacBook-Pro tmp % claude -p "Please tell me what 1 X 1 is (1)?" --output-format json | jq
{
"type": "result",
"subtype": "success",
"is_error": false,
"duration_ms": 2233,
"duration_api_ms": 2024,
"num_turns": 1,
"result": "1",
"session_id": "904cb453-04fb-4ba9-8047-9361fd58da61",
"total_cost_usd": 0.00667425,
"usage": {
"input_tokens": 3,
"cache_creation_input_tokens": 629,
"cache_read_input_tokens": 14055,
"output_tokens": 6,
"server_tool_use": {
"web_search_requests": 0
},
"service_tier": "standard"
}
}
stevepersonal@Steves-MacBook-Pro tmp %
stevepersonal@Steves-MacBook-Pro tmp % claude -p --continue "What questions, in order, have I asked in this session (2)?" --output-format json | jq
{
"type": "result",
"subtype": "success",
"is_error": false,
"duration_ms": 2251,
"duration_api_ms": 2981,
"num_turns": 3,
"result": "1. \"Please tell me what 1 X 1 is (1)?\"\n2. \"What questions, in order, have I asked in this session (2)?\"",
"session_id": "ceb533c1-1db6-4b31-ba84-7c75ea0e2a79",
"total_cost_usd": 0.0053060500000000005,
"usage": {
"input_tokens": 3,
"cache_creation_input_tokens": 23,
"cache_read_input_tokens": 14684,
"output_tokens": 44,
"server_tool_use": {
"web_search_requests": 0
},
"service_tier": "standard"
}
}
stevepersonal@Steves-MacBook-Pro tmp %
stevepersonal@Steves-MacBook-Pro tmp % claude -p --continue "What questions, in order, have I asked in this session (3)?" --output-format json | jq
{
"type": "result",
"subtype": "success",
"is_error": false,
"duration_ms": 2687,
"duration_api_ms": 2509,
"num_turns": 5,
"result": "1. \"Please tell me what 1 X 1 is (1)?\"\n2. \"What questions, in order, have I asked in this session (2)?\"\n3. \"What questions, in order, have I asked in this session (3)?\"",
"session_id": "5976e522-cd8d-4c7a-8971-f5048a90726f",
"total_cost_usd": 0.005714849999999999,
"usage": {
"input_tokens": 3,
"cache_creation_input_tokens": 61,
"cache_read_input_tokens": 14707,
"output_tokens": 71,
"server_tool_use": {
"web_search_requests": 0
},
"service_tier": "standard"
}
}
stevepersonal@Steves-MacBook-Pro tmp % This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗