Skip to content

Add parentRunId to resume runs for AG-UI protocol conformance#1

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/check-askuser-agui-compliance
Closed

Add parentRunId to resume runs for AG-UI protocol conformance#1
Copilot wants to merge 2 commits into
mainfrom
copilot/check-askuser-agui-compliance

Conversation

Copilot AI commented Apr 5, 2026

Copy link
Copy Markdown

AG-UI protocol requires RUN_STARTED events from resume runs to carry parentRunId referencing the interrupted run, creating a lineage chain. This was missing.

Changes

  • AGUIEventEmitter: Accept parent_run_id, propagate to RunStartedEvent
  • agent.run_agui(): Accept optional parent_run_id parameter
  • agent._pending_interrupt: Store run_id at interrupt time for hot-path resume lookup
  • agent_service.resume_agui(): Extract interrupted run ID from memory (hot) or DB round (cold), pass as parent_run_id
  • _load_persisted_interrupt(): Return round_id for cold recovery path
  • 4 new protocol conformance tests

After resume, the event stream now correctly emits:

{
  "type": "RUN_STARTED",
  "threadId": "thread_001",
  "runId": "run_002",
  "parentRunId": "run_001"
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • openaipublic.blob.core.windows.net
    • Triggering command: /usr/bin/python python -m pytest tests/test_ask_user_tool.py -v (dns block)
    • Triggering command: /usr/bin/python python -m pytest tests/ -v --ignore=tests/test_api_routes.py --ignore=tests/test_history_service.py --ignore=tests/test_llm.py --ignore=tests/test_startup_cleanup.py (dns block)
    • Triggering command: /usr/bin/python python -m pytest tests/test_ask_user_tool.py tests/test_agent.py -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

- AGUIEventEmitter: accept parent_run_id in constructor, pass to RunStartedEvent
- agent.run_agui(): accept parent_run_id param, pass to emitter
- agent._pending_interrupt: store run_id for resume parentRunId tracking
- agent_service._run_round_stream(): accept parent_run_id, pass to run_agui()
- agent_service.resume_agui(): extract interrupted run_id, pass as parent_run_id
- agent_service._load_persisted_interrupt(): return round_id for cold recovery
- collect_agui_events helper: support parent_run_id parameter
- Add 4 new AG-UI protocol conformance tests

Agent-Logs-Url: https://github.com/RonaldJEN/OpenCapyBox/sessions/8a4cadd0-bbbc-4521-b127-49b8fa9cafbe

Co-authored-by: RonaldJEN <36885328+RonaldJEN@users.noreply.github.com>
Copilot AI changed the title [WIP] Verify Askuser implementation against Agui protocol design Add parentRunId to resume runs for AG-UI protocol conformance Apr 5, 2026
Copilot AI requested a review from RonaldJEN April 5, 2026 12:29
@RonaldJEN

Copy link
Copy Markdown
Owner

@copilot 用中文summary下本次修改

Copilot AI commented Apr 5, 2026

Copy link
Copy Markdown
Author

@copilot 用中文summary下本次修改

本次修改的核心目标是让 ask_user 的中断/恢复流程符合 AG-UI 协议规范中关于 parentRunId 的要求。

问题:AG-UI 协议要求 resume 运行的 RUN_STARTED 事件必须携带 parentRunId,指向被中断的运行 ID,形成类似 git 的血缘链。当前实现缺失了这个关联。

改动点

  1. AGUIEventEmitter:构造函数新增 parent_run_id 参数,传递到 RunStartedEvent
  2. agent.run_agui():新增可选参数 parent_run_id,透传给 emitter
  3. agent._pending_interrupt:中断时保存当前 run_id,供恢复时查找父运行 ID
  4. agent_service.resume_agui():从内存(热路径)或数据库 round(冷路径)提取被中断运行的 ID,作为 parent_run_id 传入
  5. agent_service._load_persisted_interrupt():冷恢复路径下返回 round_id
  6. 新增 4 个协议一致性测试,验证 parentRunId 在各场景下的正确性

效果:resume 后事件流正确输出:

{
  "type": "RUN_STARTED",
  "runId": "run_002",
  "parentRunId": "run_001"
}

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