Skip to content

feat(interaction): real mid-turn steering with applied reporting - #497

Open
renanalmd wants to merge 1 commit into
openJiuwen-ai:developfrom
renanalmd:feat/mid-turn-steering
Open

feat(interaction): real mid-turn steering with applied reporting#497
renanalmd wants to merge 1 commit into
openJiuwen-ai:developfrom
renanalmd:feat/mid-turn-steering

Conversation

@renanalmd

@renanalmd renanalmd commented Aug 11, 2026

Copy link
Copy Markdown

Paired: GitHub #497GitCode !2305

What type of PR is this?

/kind feature

What does this PR do / why do we need it:

Wire send_input so hosts can steer an active round without stealing the output lease, refuse steers after the round ends, and report what reached model context.

  • SendInputResult / InputDisposition on every send_input path
  • STEER with no active round rejects (no_active_round); expected_round_id rejects round_mismatch when the client races past turn end
  • Drop undrained steers at round teardown so they cannot bleed into the next turn; emit steer.applied with dropped ids
  • Steering envelopes carry optional request ids; rails can bound a drain
  • Team leader and member steers reach the live runtime; applied/dropped surfaces for hosts
  • Unit coverage for interaction, team harness, and applied reporting

Hosts need a truthful mid-turn path. A bare success flag hid follow-up downgrades and end-of-turn races. This contract is the dependency for the JiuwenSwarm chat.steer PR.

Which issue(s) this PR fixes:

Fixes #2748

What scenarios were tested, and what were the verification results(Function, performance, reliability, etc.)

Function

  • pytest tests/unit_tests/harness/test_deep_agent_interaction.py — steer queue, expected_round_id, no_active_round, undrained drop at round end (steer-related cases passed)
  • pytest tests/unit_tests/harness/test_steering_applied.py — applied/dropped reporting
  • Team: test_steer.py, test_team_harness_steer.py, test_steer_leader.py

Reliability

  • Steer with matching expected_round_idsteer_queued
  • Wrong or stale expected_round_idround_mismatch (does not fall through to follow-up)
  • Idle steer with nothing open → no_active_round
  • Leftover queue at round end → steer.applied with empty applied and dropped ids

Contract smoke (publish install)

python -c "from openjiuwen.harness.schema.interaction import SendInputResult; print(SendInputResult)"
python -c "from openjiuwen.core.runner.runner import Runner; assert hasattr(Runner, 'steer_agent_team')"

Performance: not a target of this change.

Security: steer does not take or replace the output lease.

Self-checklist:(Please check carefully,and mark an x in the [] brackets. We will review your completion status.

    • Design: Has the solution corresponding to the PR been reviewed by the Maintainer, and have all review comments been replied to and revised
    • Test: Has the code in the PR been fully covered by UT/ST test cases, and have the newly added test cases been uploaded to the repository along with this PR or already uploaded.
    • Verification: Does the PR description contains a detailed description of the verification results regarding the achievement of the expected goals for the Feature, Refactor, and Bugfix to this PR.
    • Interface: Does it involve changes to external interfaces? The corresponding changes have been approved by the interface review organization, and the annotation information for the API has been correctly refreshed.
    • Document: Does it involve modifications to the official website documentation? If so, please submit the materials to the Doc repository in a timely manner.

Special notes for reviewers

  • Public API: SendInputResult replaces a None return from send_input. Hosts must read accepted / disposition / reason.
  • Publish this package before JiuwenSwarm bumps its pin.

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

head_sha: b52d8f00cc02046bc7593e12131895264230e212

变更摘要

此 PR 为核心交互层引入了真实的**中途转向(mid-turn steering)**机制,并附加了完整的应用报告。核心变更在于:send_input 现在返回 SendInputResult(包含 accepted/disposition/reason),STEER 模式在没有活跃轮次时会被拒绝(而非静默降级为新轮次),转向文本在轮次结束时会被排空并报告,且带请求 ID 的 SteeringInput 信封贯穿整个队列链路,使主机能够区分“仍在处理”和“已被 rail 丢弃”。

主要改动

  • DeepAgent.send_input 返回 SendInputResult 并拒绝无效转向send_input-> None 改为 -> SendInputResult,新增 InputDisposition 枚举(STEER_QUEUED/FOLLOW_UP_QUEUED/TURN_QUEUED/RESUME_QUEUED/REJECTED)。当 mode=STEER 且无活跃轮次时返回 rejected("no_active_round"),而非像旧代码那样降级为全新轮次;带 expected_round_id 的转向若不匹配则返回 rejected("round_mismatch")

  • 新增 SteeringInput 信封与全链路 ID 传递loop_queues.py 新增 SteeringInput(text, id) 数据类,push_steerenqueue_steerdrain_steering 均从裸字符串升级为支持该信封。DeepAgent.send_inputSTEER 路径中将 request.request_id 注入 SteeringInput,确保 STEER_APPLIED 事件的 dropped 列表能正确构建。

  • 新增转向应用报告与轮次结束时排空ReActAgent._report_steering_applied 在 rails 处理后报告哪些转向文本到达了模型上下文,哪些被丢弃;DeepAgent._drop_undrained_steering 在轮次结束时排空残留转向队列并发出 steer.applied 事件(applied=[])。NativeHarness._emit_interaction_event 将事件写入 output_queue,修复了 Team 客户端此前收不到 steer.applied 的问题。

  • 新增 SupportsRoundSteering 协议与 TeamAgent.steer/TeamHarness.steer_round:在 member_runtime.py 中从 MemberRuntime 分离出 SupportsRoundSteering 协议(声明 steer_round 方法),使 ExternalCliRuntime 不会因此失去 MemberRuntime 符合性。TeamAgent.steer 通过 isinstance 检查路由到运行时,不支持时抛出 NotImplementedErrorTeamHarness 新增 steer_roundactive_round 属性作为转发面。

  • TeamRuntimeManager.steer_leaderRunner.steer_agent_team:新增独立的领导者转向入口,通过 has_in_flight_round 快速检查、interact_gate 控流、以及 expected_round_id 防竞态,返回 DeliverResult 并区分 not_active/no_active_round/gate_closed/unsupported_runtime

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

head_sha: 3ca8ed02960a3bf297095973371bec838da10655

🤖 AI Code Review

⚠️ 审查未能完成

本次代码审查未能完成,可能是临时性故障。

你可以在评论区输入 /ai review 重新发起审查。若多次失败,请联系管理员并附上下方追踪 ID。

追踪 ID: task-179145-run-172043

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: b52d8f00cc02046bc7593e12131895264230e212

任务名称 结果 日志操作
静态检查 ❌FAILED 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ❌FAILED 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ❌FAILED 点此跳转

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 4795ece3f9157af3693672993bdaeda948f3dd90

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ❌FAILED 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ❌FAILED 点此跳转

Wire send_input so hosts can steer an active round without stealing the
output lease, refuse steers after the round ends, and report what reached
model context.

- SendInputResult / InputDisposition on every send_input path
- STEER with no active round rejects (no_active_round); expected_round_id
  rejects round_mismatch when the client races past turn end
- Drop undrained steers at round teardown so they cannot bleed into the
  next turn; emit steer.applied with dropped ids
- Steering envelopes carry optional request ids; rails can bound a drain
- Team leader and member steers reach the live runtime; applied/dropped
  surfaces for hosts
- Public ReActAgent.set_steering_applied_sink for host bridges; DeepAgent
  binds via duck-typing so harness test doubles keep working
- Unit coverage for interaction, team harness, and applied reporting
@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 3ca8ed02960a3bf297095973371bec838da10655

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ❌FAILED 点此跳转

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant