Skip to content

fix(#151): refresh effort from registry on context_restart; fix PUT /effort - #653

Open
olegbrok wants to merge 1 commit into
mainfrom
fix/151-effort-refresh-on-restart
Open

fix(#151): refresh effort from registry on context_restart; fix PUT /effort#653
olegbrok wants to merge 1 commit into
mainfrom
fix/151-effort-refresh-on-restart

Conversation

@olegbrok

@olegbrok olegbrok commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Why

Surfaced while dogfooding native ultracode (#151). A context_restart with the agent's stored default flipped to ultracode did not fire native /effort ultracode — the logs showed mode=fresh (continue correctly suppressed) but no native /effort activation, i.e. is_ultracode(effective_effort) was False at _build_claude_cmd time despite the DB holding ultracode.

Root cause: the live session reuses its boot-time _config, and restart_streaming_session never re-read thinking_effort from the registry. An out-of-band default change (direct DB write, or PUT /agents/{name}/effort) was invisible to the running session until a full daemon restart, so native arming evaluated a stale effort and silently skipped.

Changes

  1. restart_streaming_session refreshes effort from the registry before reconnect (agents.get(name).thinking_effort). A session-level _effort_override (set via set_thinking_effort) still wins in effective_effort, so this only makes the stored default authoritative — it never clobbers an override.

  2. PUT /agents/{name}/effort 500 fix — it called a nonexistent agents.update()AttributeError. AgentRegistry uses register() as its upsert and already handles thinking_effort on existing agents. Swapped to agents.register(name, thinking_effort=level).

Tests

  • test_put_agent_effort_persists_default — PUT persists the default and GET reflects it (regression for the 500).
  • test_streaming_restart_refreshes_thinking_effort_from_registry — out-of-band default bump is picked up on restart.
  • Sibling restart tests stay green; ruff clean.

Not included

Frontend effort selector still missing xhigh + ultracode options — separate frontend change, tracked as the remaining #151 follow-up.

🤖 Generated with Claude Code

…effort

Two #151 follow-ups surfaced while dogfooding native ultracode:

1. restart_streaming_session reused the live in-memory _config and never
   re-read thinking_effort from the registry. An out-of-band default
   change (direct DB write or PUT /agents/{name}/effort) was invisible to
   the running session until a full daemon restart — so native ultracode
   arming in _build_claude_cmd evaluated a stale effort and silently
   skipped. Refresh _config.thinking_effort from agents.get() before
   reconnect. A session-level _effort_override still wins in
   effective_effort, so this only makes the stored default authoritative.

2. PUT /agents/{name}/effort called a nonexistent agents.update() →
   AttributeError → 500. AgentRegistry uses register() as its upsert and
   already handles thinking_effort on existing agents.

Tests: regression coverage for both (PUT persists default; restart
refreshes effort from registry). Sibling restart tests stay green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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