Skip to content

fix(bus): wire injection_prompt in async inter-agent result delivery (rr#18)#118

Open
kdramapulse wants to merge 1 commit intoPleasePrompto:mainfrom
kdramapulse:feature/rr18-ductor-deliver-fix
Open

fix(bus): wire injection_prompt in async inter-agent result delivery (rr#18)#118
kdramapulse wants to merge 1 commit intoPleasePrompto:mainfrom
kdramapulse:feature/rr18-ductor-deliver-fix

Conversation

@kdramapulse
Copy link
Copy Markdown

Summary

  • Root cause: from_interagent_result() in bus/adapters.py never set envelope.prompt, so bus._process() always skipped injection and delivered raw sub-agent text directly to the user instead of routing it through the calling agent's active CLI session.
  • Fix: add injection_prompt keyword argument to from_interagent_result(); Telegram and Matrix app handlers now build the full [ASYNC INTER-AGENT RESPONSE ...] prompt and pass it in; bus._process() then calls inject_prompt() as intended, resuming the parent session and replacing result_text with the processed response.
  • Scope: bus/adapters.py, messenger/telegram/app.py, messenger/matrix/bot.py — no changes to bus lock logic, session management, or other delivery paths.

Regression tests (tests/bus/test_interagent_inject_rr18.py)

10 new tests covering all 4 required patterns:

  1. Idle deliveryinject_prompt called once, result_text replaced by injected response
  2. Main busy (lock contention) — ia-async envelope queued behind held lock, fires after release — never dropped
  3. No prompt / raw deliverinject_prompt never called when injection_prompt=""
  4. Concurrent multi-task — dev + strategy + reviewer all injected independently (3/3)

All 37 tests (adapter suite + rr#18 suite) pass.

Test plan

  • uv run --extra test pytest tests/bus/test_adapters.py tests/bus/test_interagent_inject_rr18.py → 37 passed
  • Deploy to live instance: pipx upgrade ductor + touch ~/.ductor/restart-requested
  • Fire 1 sample async inter-agent task → verify 5-step deliver chain logs appear and Main processes result
  • Verify no regression in task result injection (from_task_result path unchanged)

🤖 Generated with Claude Code

…(rr#18)

from_interagent_result() never set envelope.prompt, so bus._process()
always skipped injection and delivered raw sub-agent text instead of
passing it through the calling agent's active CLI session.

Fix: add injection_prompt kwarg to from_interagent_result(); callers
(telegram/app.py, matrix/bot.py) build the full [ASYNC INTER-AGENT
RESPONSE] prompt and pass it in. bus._process() then calls
inject_prompt() as intended, resuming the parent session with the
result and replacing result_text with the processed response.

Also adds 10 regression tests (test_interagent_inject_rr18.py) covering
idle delivery, lock-contention queueing (Main busy scenario), no-prompt
raw-deliver path, and concurrent multi-task isolation.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@kdramapulse kdramapulse marked this pull request as ready for review April 28, 2026 03:53
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