Skip to content

fix(agent,event-log): recover context overflow, allow concurrent project registration, and add opt-in host stress tests - #7083

Merged
M4n5ter merged 1 commit into
rust-previewfrom
stress/host-nightmare
Nov 20, 2026
Merged

M4n5ter merged 1 commit into
rust-previewfrom
stress/host-nightmare

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

Two real Maka Host bugs uncovered under high-concurrency / long-session stress testing, plus five opt-in (#[ignore]) real-Host stress scenarios covering JS V8 Code Mode, Python Monty Code Mode, 60-session chaos/steering/cancel storms, 40-turn cascading compaction + overflow recovery, and adversarial OOM/kill/reopen storms.

Bug Fixes

  1. plugins/agent/native/src/owner/driver_model.rs (P0 — ContextOverflow permanently wedged runs in running):

    • Exclude ModelError::ContextOverflow from terminal_outcome when purpose == ModelPurpose::Main so the model attempt interrupts instead of closing with Outcome::Error, letting the engine enter AssessModel -> AttemptRecovery::ContextOverflow -> Preparation::ContextOverflow emergency compaction.
    • Keep ModelPurpose::Summary closing with Outcome::Error so CompactionFallback continues to work.
    • Skip premature inline witness.recovery(...) for ModelError::ContextOverflow to avoid InvalidTransition("context overflow requires an original interrupted model attempt").
    • Added unit regression test context_overflow_terminal_outcome_interrupts_main_and_closes_summary.
  2. platform/event-log/src/projects/mutation.rs (P1 — concurrent SessionCreate spuriously rejected with workspace_unavailable):

    • RegistrationGuard::ObservedAvailable previously compared full ProjectRecord equality (actual != expected), causing concurrent directory SessionCreate calls to fail with ProjectError::Changed whenever another session bumped projects.last_used_at.
    • Aligned with prepare_project_selection: match on (id, identity) and reject only if archived or identity changed.
    • Added unit regression test concurrent_available_registration_ignores_last_used_at_bump_but_rejects_archive.

Opt-in (#[ignore]) Real-Host Stress Scenarios

Added in products/maka/cli/tests/mainline_reopen/host_nightmare_stress.rs (all #[ignore], never executed in default cargo test):

  • real_host_codemode_v8_and_subagent_fanout_storm (10 JS V8 parents × 2 JS V8 children = 30 concurrent sessions)
  • real_host_codemode_python_and_subagent_fanout_storm (10 Python Monty parents × 2 Python Monty children = 30 concurrent sessions)
  • real_host_60_session_incident_wave_and_steering_cancel_storm (60 mixed-protocol concurrent sessions + repeating fault waves + mid-stream steering + mid-run stop & restart)
  • real_host_40_turn_multi_compaction_and_overflow_torture (40 turns, 13 cascading compactions, 2 live HTTP 400 context_length_exceeded recoveries, 2 FinishReason::Length truncations)
  • real_host_codemode_js_and_python_adversarial_kill_oom_reopen_storm (12 simultaneous JS+Python sessions across OOM bombs, agent.stop, wait(terminate=true), follow-up turns, and full Host quit/reopen)

Verification

  • cargo fmt --check
  • node scripts/asf-license-headers.mjs check
  • cargo clippy --no-deps -p maka-cli --test mainline_reopen -- -D warnings
  • cargo test -p maka-event-log (40/40 passed)
  • cargo test -p maka-agent-native context_overflow_terminal_outcome (1/1 passed)
  • All 5 opt-in host_nightmare_stress scenarios executed live against real Maka Host and passed with 0 watchdog violations, 0 FD leaks, and 0 leaked Monty worker processes.

…ect registration, and add opt-in host stress tests
@M4n5ter
M4n5ter merged commit 0716ea7 into rust-preview Nov 20, 2026
1 check passed
@M4n5ter
M4n5ter deleted the stress/host-nightmare branch November 20, 2026 08:23
UncertaintyDeterminesYou4ndMe added a commit that referenced this pull request Nov 20, 2026
A main-model reply that stops at the output length limit goes back to the
model: a cut-off reply gets a continue cue, a cut-off tool call a
rejection, and a reply cut off while only reasoning a note asking for a
shorter answer. The Run counts these stops in agent_runs.output_limit_stops
(migration 50) and fails after the fourth, so the cap holds however the
frontier is replayed.

An Anthropic stream that stops with model_context_window_exceeded is a
provider error, so the context-overflow recovery from #7083 takes over
instead of the turn ending as a normal finish.

Generated-by: Claude Code (Claude Opus 5.5)
UncertaintyDeterminesYou4ndMe added a commit that referenced this pull request Nov 20, 2026
…l output

Since #7083 a main-model context overflow interrupts the attempt. When the
attempt's partial output never reached the canonical log (no semantic
output, no tool calls), the overflow is now compacted like a no-output
overflow instead of failing the turn, so the dropped text cannot come back
in a later replay. On OpenAI Responses an overflow after an accepted
output item still ends the turn.

The continuation tells the model its previous reply was cut off, whether
the overflow adopted a ready background summary or produced its own.

Generated-by: Claude Code (Claude Opus 5.5)
M4n5ter pushed a commit that referenced this pull request Nov 20, 2026
…l output

Since #7083 a main-model context overflow interrupts the attempt. When the
attempt's partial output never reached the canonical log (no semantic
output, no tool calls), compact and continue instead of failing the turn:

- Consolidate the safe-overflow check in Attempt::compactable_overflow()
  across state, engine, and native; OpenAI Responses attempts that already
  persisted semantic output or tool calls still end the turn.
- Reject unadmitted tool calls from ContextOverflow attempts (and wait for
  Assess while an interrupted attempt has no recovery yet) so doomed
  overflowed attempts never execute side-effecting tools before failing.
- Emit the Host cut-off note on both on-demand overflow summaries and
  adopted background proactive summaries (Action::AdoptCandidate).
- Route Anthropic stream model_context_window_exceeded to ProviderError so
  it takes the ContextOverflow compaction path instead of output-length
  continuation.
M4n5ter pushed a commit that referenced this pull request Nov 20, 2026
…l output (#7055)

Since #7083 a main-model context overflow interrupts the attempt. When the
attempt's partial output never reached the canonical log (no semantic
output, no tool calls), compact and continue instead of failing the turn:

- Consolidate the safe-overflow check in Attempt::compactable_overflow()
  across state, engine, and native; OpenAI Responses attempts that already
  persisted semantic output or tool calls still end the turn.
- Reject unadmitted tool calls from ContextOverflow attempts (and wait for
  Assess while an interrupted attempt has no recovery yet) so doomed
  overflowed attempts never execute side-effecting tools before failing.
- Emit the Host cut-off note on both on-demand overflow summaries and
  adopted background proactive summaries (Action::AdoptCandidate).
- Route Anthropic stream model_context_window_exceeded to ProviderError so
  it takes the ContextOverflow compaction path instead of output-length
  continuation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant