anthropics / anthropics/claude-agent-sdk-python
Feature: Max turns before compact
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 1.3k
- Avg merge
- 2d 31m
- Merged PRs (30d)
- 1
Description
I've seen `--max-turns` but really that's not what I want, I want to be able to control the autoCompact so that I can set how many messages are loaded into the history before compacting. I don't need it to reach 95% of the context before compacting.
Today I noticed the response from one of my sessions: `num_turns=231`
```
[CLAUDE RAW MESSAGE] ResultMessage(
subtype='success',
duration_ms=213207,
duration_api_ms=162411,
is_error=False,
num_turns=231,
total_cost_usd=0.6639560999999999,
usage={
input_tokens: 156,
cache_creation_input_tokens: 55539,
cache_read_input_tokens: 679910,
output_tokens: 2136,
server_tool_use: {
web_search_requests: 0
},
service_tier: 'standard'
},
result='No response requested.'
)
```
I was surprised and that is far more than I had expected.
Unfortunately, I have no insight into what point autocompacts happened. It would be great to be able to control this to reduce the resources used and speed up responses.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how --max-turns and autoCompact are handled, then inspect how message history is selected before compaction. Define how a configurable history limit should interact with the existing 95% context behavior, and verify that compaction occurs at the configured limit while reducing unnecessary turns and resource use.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100