Skip to content

fix(orchestrator): use active session's provider/model when injecting prompts#142

Open
ryuhaneul wants to merge 1 commit into
PleasePrompto:mainfrom
ryuhaneul:fix/inject-prompt-provider-model
Open

fix(orchestrator): use active session's provider/model when injecting prompts#142
ryuhaneul wants to merge 1 commit into
PleasePrompto:mainfrom
ryuhaneul:fix/inject-prompt-provider-model

Conversation

@ryuhaneul
Copy link
Copy Markdown
Contributor

Background

_inject_prompt in orchestrator/injection.py builds the AgentRequest
without provider_override or model_override, so CLIService falls
back to the bot's default provider/model.

Sessions are per-topic (SessionKey(transport, chat_id, topic_id)), so a
single chat can have one topic on Codex and another on Claude even when
the bot default is claude. When the default disagrees with the topic's
active session provider, --resume <sid> hits the wrong CLI:

CLI stderr: No conversation found with session ID: <sid>
CLI returned empty output (exit=1)

The empty result becomes the envelope's result_text and surfaces in
the user chat as the visible reply, even though the task completed
normally (status=done or failed). The same path covers async
inter-agent result injection, so sub-agent results into a
different-provider topic hit it too.

Same family as #82/#81 (d38d738), which added a stale-session marker
and retry to handle_interagent_message. The _inject_prompt path was
not covered.

Proposed change

Reuse the already-resolved active session and pass its provider/model:

provider_override=active.provider if active else None,
model_override=active.model if active else None,

When active is None, both stay None and behavior is unchanged.

Consistency

Other resume sites already pass per-session provider/model — e.g.
flows.named_session_flow uses provider_override=ns.provider, model_override=ns.model. The inject path was the odd one out.

Test plan

  • Added tests/orchestrator/test_injection.py mocking get_active
    and asserting the captured AgentRequest uses the active
    session's provider/model (and falls back to None when no active
    session).
  • ruff check, ruff format --check, mypy clean.
  • Manual repro on a Codex-active topic with Claude default,
    status=done task. Before: No conversation found … in user
    chat. After: result delivered cleanly.

… prompts

_inject_prompt builds AgentRequest without provider_override/model_override,
so CLIService falls back to the bot's default. Sessions are per-topic, so a
chat can have one topic on Codex and another on Claude even when the default
is claude. When the default disagrees with the topic's active session,
--resume goes to the wrong CLI and emits "No conversation found with session
ID:" — surfaced to the user although the task completed. Same path covers
async inter-agent result injection.

Same family as PleasePrompto#82/PleasePrompto#81 (d38d738), which added a retry in
handle_interagent_message but did not cover the _inject_prompt path.

Reuse active session's provider/model; fall back to None when no active
session exists. Add unit tests covering codex/claude/None active.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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