Repository navigation
[Agent Core] 为 Python Run 建立墙钟截止时间基础 - #159
Merged
rojim666 merged 1 commit intoSep 11, 2026
Merged
Conversation
Signed-off-by: Ace <1160684883@qq.com>
z2Ace0107
force-pushed
the
codex/issue-69-pr01-deadline-foundation
branch
from
September 11, 2026 06:29
fb09b1d to
c7c15f2
Compare
rojim666
marked this pull request as ready for review
September 11, 2026 07:46
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Deadline enforcement remains incomplete around late model requests and the verification/repair phase.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR establishes monotonic wall-clock deadlines for Python runtime runs.
Changes:
- Adds non-resetting deadlines and
remaining_s(). - Initializes deadlines before run execution.
- Handles timeout outcomes and late results.
- Adds unit and integration coverage.
File summaries
| File | Summary |
|---|---|
py-runtime/tests/unit/test_runner.py |
Tests deadline initialization order. |
py-runtime/tests/unit/test_loop.py |
Tests loop timeout behavior. |
py-runtime/tests/unit/test_context.py |
Tests deadline lifecycle and exhaustion. |
py-runtime/tests/integration/test_deadline_foundation.py |
Adds deadline integration coverage. |
py-runtime/src/sztu_code/core/runner.py |
Initializes deadlines before run.started. |
py-runtime/src/sztu_code/core/loop.py |
Adds deadline checks and late-result handling. |
py-runtime/src/sztu_code/core/context.py |
Implements deadline state and remaining-time API. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
764
to
+765
| elif context.wall_clock_exceeded(): | ||
| context.mark_interrupted("max_wall_clock_exceeded") | ||
| context.mark_interrupted(TerminationReason.MAX_WALL_CLOCK_EXCEEDED) |
Comment on lines
+371
to
+372
| # 固定完整 Run 的墙钟起点,覆盖 run.started 事件之后的 provider/registry 初始化。 | ||
| context.start() |
Comment on lines
+379
to
+381
| context.mark_interrupted(TerminationReason.MAX_WALL_CLOCK_EXCEEDED) | ||
| else: | ||
| context.mark_failed("max_wall_clock_exceeded") | ||
| context.mark_failed(TerminationReason.MAX_WALL_CLOCK_EXCEEDED) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
这是 Issue #69 的第一个可独立 Review 的 PR,范围仅限 Python runtime 的 Run deadline foundation。
Behavior
Runner 会在发布 run.started 之前固定墙钟起点,直接调用 AgentLoop.run() 时也会初始化 deadline。deadline 到达后,AgentLoop 不会再开始新的模型请求;如果模型响应已经迟到,仍保留其文本结果,但不会错误地报告为 success。
本 PR 基于当前 main。当前 main 已包含已合并的 #158(权限审批取消流程清理),本 PR 不重复修改权限生命周期逻辑。
Provider、工具、权限等待、Subagent、retry、compaction、cleanup 和 Trace 的剩余时间传播属于后续独立 PR,本 PR 不声称完整解决 #69。
Validation
Risk
本 PR 只提供统一 deadline 的基础设施,不会取消正在执行的 Provider 或工具 await,也不会改变权限响应协议。后续 PR 将在此基础上接入剩余时间、硬截止、取消清理和统一终止事件。
UI evidence
N/A:无 TUI 或桌面端视觉变化。
Checklist
Refs #69