Skip to content

fix(bub-acp-server): stop leaking "auto" effort and harden session store - #103

Merged
frostming merged 1 commit into
bubbuild:mainfrom
Gabyran:fix/acp-auto-effort-and-session-store-race
Nov 11, 2026
Merged

frostming merged 1 commit into
bubbuild:mainfrom
Gabyran:fix/acp-auto-effort-and-session-store-race

Conversation

@Gabyran

@Gabyran Gabyran commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Two robustness issues in bub-acp-server, both hit in real multi-session usage:

  1. The literal string "auto" is forwarded as reasoning_effort into model requests.
    auto is the ACP-facing placeholder for "no explicit effort" (the default of the session config option), but _build_inbound passes it through verbatim. Strict providers reject it (400 invalid_request_error: Invalid value: 'auto', observed on two different gateways); lenient ones silently ignore it. So sessions either fail or run with unpredictable thinking behavior depending on the route.

  2. Concurrent bub acp instances crash on startup with ENOENT.
    All instances share <BUB_HOME>/acp-sessions.json and _save_sessions() writes it through a fixed .json.tmp temp name followed by replace(). When several instances start at once (e.g. an orchestrator spawning several ACP sessions), one process renames the temp file away before the other's replace(), and the losing process crashes:
    [Errno 2] No such file or directory: '.../acp-sessions.json.tmp' -> '.../acp-sessions.json'

Fix

  • Skip _runtime_reasoning_effort when the configured value is auto, so each model uses its own default behavior — matching what "auto" means in the UI.
  • Persist the session store through a per-process temp file (.json.<pid>.tmp) and treat a lost replace() race as a lost update instead of crashing.

Tests

  • test_auto_reasoning_effort_is_not_forwarded: a session configured with auto must not leak _runtime_reasoning_effort into the model request context.
  • test_save_sessions_tolerates_concurrent_store_rotation: a replace() that loses the race must not raise and must not leave temp files behind.
  • Full packages/bub-acp-server suite: 211 passed; ruff check and format clean.

Two robustness fixes for concurrent and multi-provider ACP usage:

1. Never forward the literal "auto" reasoning effort into model
   requests. "auto" is the ACP-facing placeholder for "no explicit
   effort"; providers reject the literal value (400
   invalid_request_error on strict routes) or silently ignore it, so
   sessions either failed or ran with unpredictable thinking behavior
   depending on the gateway route. Skip the field and let each model
   use its own default.

2. Persist acp-sessions.json through a per-process temp file and
   tolerate a lost replace() race. Concurrent `bub acp` instances
   share the store; with the fixed ".json.tmp" name, one process
   renaming the temp file crashed the other with FileNotFoundError
   during startup.
@Gabyran
Gabyran force-pushed the fix/acp-auto-effort-and-session-store-race branch from 26f569f to 7c6017c Compare November 11, 2026 07:22
@frostming
frostming merged commit 98d5581 into bubbuild:main Nov 11, 2026
2 checks passed
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.

2 participants