Skip to content

fix: a working turn is not cut by a clock, only an idle one ends (4.102.0) - #175

Merged
CocoRoF merged 1 commit into
mainfrom
fix/long-turn-alive
Oct 24, 2026
Merged

CocoRoF merged 1 commit into
mainfrom
fix/long-turn-alive

Conversation

@CocoRoF

@CocoRoF CocoRoF commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

무엇이 문제였나

DEV 에서 긴 Agent-Geny 턴(긴 빌드, 연이은 도구 호출)이 일하는 중에 끊겼습니다. 시간 한도가 모두 시작부터 센 고정값이었습니다.

  • 호스트(xgen-workflow)가 거는 RunBudget(max_wall_seconds≤300)·CancellationScope(deadline≤300s): 턴 시작 5분 뒤 모든 도구·모델 호출이 거절됩니다.
  • CLI(claude_code·codex) 스트림: timeout_s(기본 3600초)를 시작부터 세서, 일하는 중이어도 1시간에 CLI 를 죽였습니다.

바꾼 것

  • RunBudget(max_idle_seconds=…) 유휴 모드: 아무 일도 없이(모델·도구 호출이 없고 도는 것도 없이) 그만큼 지나야 끝납니다. 도는 도구(reserverelease)와 도는 모델 호출(begin_model_callend_model_call)은 활동입니다. max_wall_seconds 는 상한이 됩니다. 기본(유휴 모드 아님)은 예전과 같습니다.
  • max_total_result_bytes: 턴 전체 결과 바이트 상한을 결과 하나의 상한과 따로 둡니다.
  • Stage 6 이 모델 호출을 도는 동안 호스트에 알립니다(bind_run_guard → _host_model_activity). 라우터의 임시 취소 범위는 마감을 한 번 읽지 않고 예산에 매번 묻습니다.
  • CLI: timeout_s 가 유휴 한도입니다(출력도 도구 활동도 없이 그만큼). 브릿지 도구가 도는 동안 CLI 는 출력이 없으므로 도구 표면이 활동을 알립니다(TurnToolSurface.idle_seconds → set_activity_probe).

시험

  • 새 tests/unit/test_long_turn_alive.py 8개: 도는 도구·모델 호출이 유휴 예산을 열어 두는지, 꾸준한 활동이 예전 고정 한도를 넘기고 상한은 지키는지, 기본 예산은 그대로인지, 출력이 이어지는 CLI 는 한도를 넘어 돌고 조용한 CLI 는 도구가 돌면 기다리고 아무 일도 없으면 멈추는지, 표면의 활동, Stage 6 훅.
  • 전체 6,257 통과, ruff check·format, mypy(core·llm_client).

🤖 Generated with Claude Code

…02.0)

Long agent turns (a long build, a run of tool calls) were stopped while working: every time limit
counted from the start.

- RunBudget(max_idle_seconds=...): idle mode. The run ends only after that long with nothing
  happening; a tool in flight (reserve to release) and a provider call in flight (begin_model_call
  to end_model_call) are activity. max_wall_seconds becomes the hard ceiling. The default (no idle
  mode) is unchanged. expired(), idle_seconds(), touch().
- max_total_result_bytes bounds all of a run's results apart from one result's cap.
- Stage 6 tells the host while a provider call is in flight (_host_model_activity from
  bind_run_guard). The router's ad hoc scope asks the budget each tick instead of reading its
  deadline once.
- CLI clients: timeout_s is an idle limit (no output and no tool activity). The CLI prints
  nothing while a bridged tool runs, so the turn's tool surface reports when its tools were last
  busy (TurnToolSurface.idle_seconds, set_activity_probe). Before, the CLI was killed at the hour.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@CocoRoF
CocoRoF merged commit 92f89d4 into main Oct 24, 2026
7 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.

1 participant