Skip to content

fix(SRC): 增强SRC的日志匹配要求并调用SRC内置模块进行进程清理, Fixes #337 - #346

Open
HarcoChen wants to merge 3 commits into
AUTO-MAS-Project:devfrom
HarcoChen:fix/harden-src
Open

fix(SRC): 增强SRC的日志匹配要求并调用SRC内置模块进行进程清理, Fixes #337#346
HarcoChen wants to merge 3 commits into
AUTO-MAS-Project:devfrom
HarcoChen:fix/harden-src

Conversation

@HarcoChen

@HarcoChen HarcoChen commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #337

  • 将日志命中逻辑增强为 | CRITICAL | Request human takeover以避免traceback错误命中
  • 杀死src.exe后额外调用SRC内置的清理程序清理SRC的Python进程

Summary by Sourcery

收紧 SRC 日志匹配规则用于人工接管检测,并在终止 SRC 进程后调用 SRC 内置清理模块。

Bug Fixes:

  • 更新 SRC 日志状态检测逻辑,仅在出现 CRITICAL 级别请求时触发人工接管,避免因通用 traceback 信息导致的误报。

Enhancements:

  • 在杀死 src.exe 和相关脚本进程后,运行 SRC 工具包的 Python 模块,以清理残留的 SRC Python 进程。
Original summary in English

Summary by Sourcery

Tighten SRC log matching for human takeover detection and invoke SRC’s built-in cleanup module after terminating SRC processes.

Bug Fixes:

  • Update SRC log status detection to only trigger human takeover on CRITICAL-level requests, avoiding false positives from generic traceback messages.

Enhancements:

  • Run the SRC toolkit Python module to clean up residual SRC Python processes after killing src.exe and related script processes.

@HarcoChen
HarcoChen requested a lite review from Copilot August 9, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sourcery-ai

sourcery-ai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

此 PR 收紧了 SRC 日志匹配用于检测人工接管,并在杀死进程后增加了一个清理步骤,调用 SRC 自带的 Python 工具包来清理残留的 SRC Python 进程。

set_src 中 SRC 进程清理的时序图

sequenceDiagram
    participant AutoProxy
    participant SrcProcessManager as src_process_manager
    participant System
    participant ProcessRunner

    AutoProxy->>SrcProcessManager: kill
    AutoProxy->>System: kill_process(src_exe_path)
    AutoProxy->>ProcessRunner: run_process(toolkit/python.exe, -m, deploy.Windows.alas, cwd=src_root_path)
Loading

check_log 中收紧日志匹配的时序图

sequenceDiagram
    participant AutoProxy

    AutoProxy->>AutoProxy: check_log(log_content, latest_time)
    alt [any " | CRITICAL | Request human takeover" in log_content]
        AutoProxy->>AutoProxy: set cur_user_log.status = "SRC 无法继续执行任务, 需要用户接管"
    else ["Close game during wait" in log]
        AutoProxy->>AutoProxy: set cur_user_log.status = "Success!"
    end
Loading

文件级变更

Change Details Files
在杀死 src.exe 之后调用 SRC 内置的清理模块,确保残留的 Python 进程被终止。
  • 扩展工具类导入以包含用于运行外部进程的 ProcessRunner。
  • 在杀死已有的 SRC 相关进程之后,运行工具包中的 python.exe 并载入 deploy.Windows.alas 模块,将 cwd 设置为 SRC 根路径。
app/task/SRC/AutoProxy.py
通过匹配特定的 CRITICAL 日志行而不是宽泛的子串搜索,使人工接管检测更加精确。
  • 更改日志检查逻辑,逐行扫描日志,匹配精确模式 "
CRITICAL

可能关联的问题


Tips and commands

与 Sourcery 交互

  • 触发新的审核: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审核评论。
  • 从审核评论生成 GitHub issue: 通过回复某条审核评论,请 Sourcery 从该评论创建一个 issue。你也可以在审核评论下回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来随时(重新)生成摘要。
  • 生成审核者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成审核者指南。
  • 批量解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve 来标记所有 Sourcery 评论为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 批量忽略所有 Sourcery 审核: 在 pull request 中评论 @sourcery-ai dismiss 来忽略所有现有的 Sourcery 审核。如果你想从一次全新的审核开始,这特别有用——别忘了再评论 @sourcery-ai review 来触发新的审核!

自定义你的使用体验

访问你的仪表盘以:

  • 启用或停用审核功能,例如 Sourcery 生成的 pull request 摘要、审核者指南等。
  • 更改审核语言。
  • 添加、删除或编辑自定义审核说明。
  • 调整其他审核设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR tightens SRC log matching for human takeover detection and adds a post-kill cleanup step that invokes SRC’s bundled Python toolkit to clean residual SRC Python processes.

Sequence diagram for SRC process cleanup in set_src

sequenceDiagram
    participant AutoProxy
    participant SrcProcessManager as src_process_manager
    participant System
    participant ProcessRunner

    AutoProxy->>SrcProcessManager: kill
    AutoProxy->>System: kill_process(src_exe_path)
    AutoProxy->>ProcessRunner: run_process(toolkit/python.exe, -m, deploy.Windows.alas, cwd=src_root_path)
Loading

Sequence diagram for tightened log matching in check_log

sequenceDiagram
    participant AutoProxy

    AutoProxy->>AutoProxy: check_log(log_content, latest_time)
    alt [any " | CRITICAL | Request human takeover" in log_content]
        AutoProxy->>AutoProxy: set cur_user_log.status = "SRC 无法继续执行任务, 需要用户接管"
    else ["Close game during wait" in log]
        AutoProxy->>AutoProxy: set cur_user_log.status = "Success!"
    end
Loading

File-Level Changes

Change Details Files
Invoke SRC’s built-in cleanup module after killing src.exe to ensure residual Python processes are terminated.
  • Extend utility imports to include ProcessRunner for running external processes.
  • After killing existing SRC-related processes, run the toolkit’s python.exe with the deploy.Windows.alas module, setting cwd to the SRC root path.
app/task/SRC/AutoProxy.py
Make human takeover detection more precise by matching the specific CRITICAL log line instead of a broad substring search.
  • Change log inspection to scan individual log lines for the exact pattern "
CRITICAL

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些宏观层面的反馈:

  • 新的 ProcessRunner.run_process 调用假设 toolkit/python.exedeploy.Windows.alas 模块总是存在;建议添加错误处理或预检查,这样当这个清理步骤失败时,可以清晰地暴露问题,而不是在不知不觉中破坏整个安装流程。
  • 更新后的人工接管日志匹配条件依赖于对 " | CRITICAL | Request human takeover" 的硬编码子串搜索;建议使用更结构化的方式(例如分别解析日志级别和消息,或者使用正则表达式进行匹配),以避免在日志格式稍有变化时变得脆弱。
给 AI 代理的提示
请根据这次代码评审的评论进行修改:

## 整体评论
- 新的 `ProcessRunner.run_process` 调用假设 `toolkit/python.exe``deploy.Windows.alas` 模块总是存在;建议添加错误处理或预检查,这样当这个清理步骤失败时,可以清晰地暴露问题,而不是在不知不觉中破坏整个安装流程。
- 更新后的人工接管日志匹配条件依赖于对 `" | CRITICAL | Request human takeover"` 的硬编码子串搜索;建议使用更结构化的方式(例如分别解析日志级别和消息,或者使用正则表达式进行匹配),以避免在日志格式稍有变化时变得脆弱。

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've left some high level feedback:

  • The new ProcessRunner.run_process invocation assumes toolkit/python.exe and the deploy.Windows.alas module always exist; consider adding error handling or a pre-check so failures in this cleanup step are surfaced clearly rather than silently breaking the setup flow.
  • The updated log matching condition for human takeover relies on a hardcoded substring search for " | CRITICAL | Request human takeover"; consider using a more structured approach (e.g., parsing log level and message separately or matching against a regex) to avoid brittleness if the log format changes slightly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `ProcessRunner.run_process` invocation assumes `toolkit/python.exe` and the `deploy.Windows.alas` module always exist; consider adding error handling or a pre-check so failures in this cleanup step are surfaced clearly rather than silently breaking the setup flow.
- The updated log matching condition for human takeover relies on a hardcoded substring search for `" | CRITICAL | Request human takeover"`; consider using a more structured approach (e.g., parsing log level and message separately or matching against a regex) to avoid brittleness if the log format changes slightly.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

[Bug] SRC 结束后残留 Python 后端,崩溃堆栈可能触发「需要用户接管」误判

2 participants