Repository navigation
test(runtime): Claude 5.x lifecycle — compaction, reload, switches, shared clients #4654
Copy link
Copy link
Closed
Copy link
Labels
area/providersFor features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.)For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.)area/providers/anthropicFor features/issues/fixes related to the usage of Anthropic modelsFor features/issues/fixes related to the usage of Anthropic modelsarea/runtimeRuntime engine, agent loop execution, tool dispatch, loop detectionRuntime engine, agent loop execution, tool dispatch, loop detectionarea/sessionsFor features/issues/fixes related to session lifecycle (resume, persistence, export)For features/issues/fixes related to session lifecycle (resume, persistence, export)area/testingTest infrastructure, CI/CD, test runners, evaluationTest infrastructure, CI/CD, test runners, evaluation
Description
Goal
Check that the Claude 5.x core holds up across the real session lifecycle: compaction, reload, model and transport switches, and several sessions sharing one client.
Test cost matters. Each behavior is pinned by the cheapest test that covers it: unit or converter level first, then request capture through a transport wrapper (as in pkg/model/provider/providers/claude5_requests_test.go), and a full runtime with a fake server only where the runtime integration itself is the point (compaction, reload, continuation). No new fake server per transport: in particular, no Bedrock event-stream fake server.
Delivery: three PRs, in order
| PR | Scope | Size |
|---|---|---|
| 1 | Pricing (Haiku 5.5 tier boundary, serving model after reload) and concurrent sessions on one client; no new harness needed | S |
| 2 | End-to-end runtime harness (factory, runtime, existing Anthropic SSE script, SQLite reload); compaction lifecycle on Anthropic Direct, plus two compaction bug fixes | M |
| 3 | Switch and reload across Direct, Vertex and Bedrock at the request level; results table | S–M |
Scope
- Local compaction triggered by the token threshold, with thinking-bearing turns: the summary goes through a checked clone, is persisted, survives a SQLite reload, and the first continuation is valid.
- Under the default
drop_blockbinding the continuation succeeds: the server drops thinking whose prefix changed. - An edited thinking turn inside the active tool loop is refused locally, and the context is not cleared.
- Under the default
- Native on-demand compaction (Direct only): real client, persisted signed block, reload, and the continuation starts with the verbatim block. A refusal or a missing summary leaves the context intact. Iteration usage reaches the stored usage and cost.
- The stream shape (whole block at
content_block_start, no deltas) is already covered at the client level. - Vertex rejects
native_compactionat construction (vertex.go). Bedrock lacks the capability, and the runtime reports it (AWS compaction).
- The stream shape (whole block at
- Switches: route, then switch model or transport (a new provider) and clone (summary and title calls), add an attachment, reload, and continue, on each of the three transports. Covers what happens to recorded thinking across transports: replayed verbatim, flattened, or omitted. Bedrock is covered by request capture and the existing adapter-level tests, not by streamed responses.
- Shared clients: two concurrent sessions on one client, with different attachments, tools and system prompts, don't leak state into each other (AGENTS.md, "Client and Session Lifetimes"). Run under
-race. - Pricing:
- Haiku 5.5's 100,000-token tier at 99,999 / 100,000 / 100,001 prompt tokens, cache reads and writes included, on Direct, Vertex and Bedrock. The tier mechanism already exists; only tests are missing.
- The serving model from fix: price routed turns using the serving model #4579 survives save and reload.
- Vertex Claude is priced at Claude API rates as a best estimate. Regional and multi-region surcharges are not modelled; the docs say so.
Bugs found while planning (fixed in PR 2)
- A native compaction block can be replayed to Vertex.
ReplayableCompactiononly compares the provider name (compaction.go), which Direct and Vertex share. After a Direct native compaction and a switch to Vertex, the signed block and its beta are sent to Vertex. - Native compaction picks the price tier from summed iterations. Iteration usage is added up (compaction.go) before the tier is chosen, so two iterations of 60k tokens are priced as one 120k request. Each request should be priced on its own (pricing).
Out of scope (separate issues)
- Persisting "unpriced" so it doesn't read as $0 after reload: fix(runtime): keep unpriced turns distinguishable from free ones after reload #4683
- Removing
rulebased.Client.lastSelectedID: refactor(rulebased): remove the client-wide lastSelectedID #4684 - Pruning the runtime
DeferralTracker: fix(runtime): prune and persist the tool DeferralTracker #4685
Acceptance criteria
- Each scenario above pinned by the cheapest test that covers it; end to end (real factory, runtime, fake server) where the runtime integration is the point. Testing a hook on its own doesn't count for those.
- Both bugs above fixed, each with a test that failed first.
-
go test -race -shuffle=onpasses on the runtime and provider packages. - A results table per model × transport × feature: pass / fail / not established / expected refusal.
-
task build,task test,task lintpass.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/providersFor features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.)For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.)area/providers/anthropicFor features/issues/fixes related to the usage of Anthropic modelsFor features/issues/fixes related to the usage of Anthropic modelsarea/runtimeRuntime engine, agent loop execution, tool dispatch, loop detectionRuntime engine, agent loop execution, tool dispatch, loop detectionarea/sessionsFor features/issues/fixes related to session lifecycle (resume, persistence, export)For features/issues/fixes related to session lifecycle (resume, persistence, export)area/testingTest infrastructure, CI/CD, test runners, evaluationTest infrastructure, CI/CD, test runners, evaluation
Activity
aheritier commentedon Oct 21, 2026
Results: Claude 5.x lifecycle (#4654)
Legend:
Models: Fable 5 / 5.1, Mythos 5 / 5.1, Opus 5 / 5.5, Sonnet 5 / 5.5, Haiku 5.5. "Prefix-checked" models are the ones whose thinking blocks the API checks against their prefix: Fable 5.1, Opus 5.5, Sonnet 5.5, Haiku 5.5.
TestLookupClaude5,TestClaude5Capabilities,TestClaude5Predicates@versionIDs)-vNIDs); 🚫 Mythos 5 outside Mantle:TestNewClient_RefusesMythos5TestClaude5FinalRequests(standard, beta, binding)TestClaude5FinalRequests/vertexTestClaude5FinalRequests/bedrock_converse,TestBuildRequest_Claude5drop_blockbinding on prefix-checked modelsTestThinkingBindingBehavior,TestApplyThinkingBindingTestThinkingBindingBehavior/vertex,TestClaude5SwitchAfterReloadTestReplayContent_*,TestClaude5SwitchAfterReload/same_modelTestClaude5SwitchAfterReload/transport_switch_to_vertexTestNativeReasoning_RoundTrip,TestConvertAssistantContent_ReplaysNativeBlocksTestClaude5SwitchAfterReload/model_switch_to_haiku_5.5TestClaude5SwitchAfterReload/transport_switch_to_vertexTestClaude5SwitchAfterReload/transport_switch_to_bedrockTestForeignProviderStateKeepsThinkingTestClaude5SwitchAfterReloadTestUnreplayableRawStateTestUnreplayableNativeBlocksTestClaude5LocalCompactionLifecycleTestClaude5NativeCompactionLifecycle,TestCompaction_*TestRejectClaudeAPIOnlyFeatures; the block isn't replayed:TestVertexDoesNotReplayCompactionBlockTestNativeCompactionRejectsUnsupportedModel(generic provider)TestCompactConversation_Safeguards(includingrefusal),TestNativeCompactionErrorLeavesTranscriptIntact,TestNativeCompactionEmptySummaryIsNoopTestNativeCompactionPricesEachIteration,TestCompactionCostUnpricedIterationTestEmbeddedSnapshotHaiku55ContextTierglobal.andus.rowsTestRoutedPricing/catalog_leaf_survives_reload(runtime, transport-independent)TestSharedClientConcurrentSessions(-race)Delivered by #4686 (PR 1, merged), #4688 (PR 2, merged) and #4689 (PR 3). Out of scope: #4683, #4684, #4685.
Follow-up to consider: Google Cloud now documents on-demand compaction (beta), while docker-agent rejects
native_compactionon Vertex.