Skip to content

fix(streaming): add missing f-prefix to phase_id on agent pause#192

Open
Osamaali313 wants to merge 1 commit into
vamplabAI:mainfrom
Osamaali313:fix/phase-id-fstring
Open

fix(streaming): add missing f-prefix to phase_id on agent pause#192
Osamaali313 wants to merge 1 commit into
vamplabAI:mainfrom
Osamaali313:fix/phase-id-fstring

Conversation

@Osamaali313

Copy link
Copy Markdown

Problem

Three streaming_generator.finish(...) calls pass phase_id as a plain string that was meant to be an f-string:

self.streaming_generator.finish(
    phase_id="{self._context.iteration}-final", content=self._context.execution_result
)

at sgr_agent_core/base_agent.py:249 and sgr_agent_core/agents/dialog_agent.py:65 and :76. Missing the f prefix, so the literal text {self._context.iteration}-final is sent verbatim instead of the interpolated <iteration>-final.

phase_id becomes the emitted SSE chunk's id (OpenAIStreamingGenerator.finish_create_base_chunk, inherited by OpenWebUIStreamingGenerator). So the terminal streaming chunk on every agent pause/hand-off — the clarification path (BaseAgent._execution_step) and the DialogAgent ClarificationTool / AnswerTool "pass turn to user" paths (every DialogAgent turn) — ships a constant, invalid id.

The correct sibling in the same file proves intent — base_agent.py:308 (the finally-block finish) already uses:

phase_id=f"{self._context.iteration}-final", ...

Reproduction

With self._context.iteration == 3:

  • Before: emitted chunk id = '{self._context.iteration}-final' (literal)
  • After: id = '3-final'

Fix

Add the f prefix at the three sites:

phase_id=f"{self._context.iteration}-final",

python -m py_compile passes for both files. (tests/test_dialog_agent.py already executes the dialog_agent.py:76 pause path but doesn't assert phase_id, which is why the literal slipped through.)

Three finish() calls pass phase_id="{self._context.iteration}-final" without
the f-string prefix, so the literal text "{self._context.iteration}-final" is
sent instead of the interpolated "<iteration>-final". phase_id becomes the
emitted SSE chunk's id (OpenAIStreamingGenerator.finish -> _create_base_chunk),
so the terminal chunk on every clarification/answer pause ships a constant,
invalid id. The correct sibling call in base_agent.py (the finally-block
finish) already uses f"{self._context.iteration}-final", proving intent. Add
the f prefix at the three sites (base_agent.py and dialog_agent.py x2).
Copilot AI review requested due to automatic review settings July 15, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

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