Skip to content

fix(llm): correct ContextManagement serialization for Claude server compaction API#1709

Merged
bug-ops merged 1 commit intomainfrom
context-management-format
Mar 13, 2026
Merged

fix(llm): correct ContextManagement serialization for Claude server compaction API#1709
bug-ops merged 1 commit intomainfrom
context-management-format

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 13, 2026

Summary

  • Fixes --server-compaction flag which caused a 400 Bad Request on every request with context_management.type: Extra inputs are not permitted
  • ContextManagement now serializes to the correct Claude API format: { "type": "auto_truncate", "trigger": { "type": "input_tokens", "value": N }, "pause_after_compaction": false }
  • Replaces the removed ContextManagementType enum with two plain structs (ContextManagement + ContextManagementTrigger) using &'static str for type discriminants

Root Cause

PR #1696 introduced the ContextManagement struct with wrong field names:

  • type: "enabled" → should be "auto_truncate"
  • trigger_tokens: u32 (flat) → should be nested trigger: { type: "input_tokens", value: N }

Test plan

  • All 4 context_management_* unit tests pass with the correct JSON assertions
  • Full suite: 5348 tests passed, 0 failures
  • cargo +nightly fmt --check clean
  • cargo clippy --workspace --features full -- -D warnings clean

Closes #1705

…ompaction API

The ContextManagement struct was serializing as:
  { "type": "enabled", "trigger_tokens": 50000 }

The Claude API expects:
  { "type": "auto_truncate", "trigger": { "type": "input_tokens", "value": 50000 }, "pause_after_compaction": false }

This mismatch caused a 400 Bad Request on every request with
--server-compaction enabled, making the feature completely non-functional.

Restructure ContextManagement into two structs (ContextManagement +
ContextManagementTrigger) with correct field names and values.
Update tests to assert the correct JSON shape.

Closes #1705
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 23:10
@github-actions github-actions Bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes bug Something isn't working size/S Small PR (11-50 lines) labels Mar 13, 2026
@bug-ops bug-ops merged commit 291b5c6 into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the context-management-format branch March 13, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/S Small PR (11-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(llm): ContextManagement serialization format wrong for Claude server compaction API

1 participant