[Bug] SequentialAgent live mode glues the completion instruction onto the sub-agent instruction with no separator

未關閉
#8,312 0 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 3 天內回覆

@llalitkumarrr 已經在處理了。

開始於 2026年11月23日。

  • #8313 來自 @shengzhaowei —— 未關閉

評估

這個 Issue 還沒有評估資料。

描述

[Bug] SequentialAgent live mode glues the completion instruction onto the sub-agent instruction with no separator

Describe the Bug

In live mode, SequentialAgent appends a completion instruction ("If you finished the user's request ... call the task_completed function ...") to each sub-agent's instruction so the model knows how to hand off to the next agent. The append is a bare string concatenation with no separator, so a sub-agent instruction ending in normal text gets glued to the suffix:

  • sub-agent instruction: You are helpful.
  • after one live run: You are helpful.If you finished the user's request ...

The model receives a malformed sentence boundary (helpful.If) instead of two separate paragraphs. It happens on every live run whose sub-agent instruction does not already end with whitespace.

Steps to Reproduce

  1. Install google-adk from main (2.15.0, commit 2b90353).
  2. Run:
from google.adk.agents.sequential_agent import _append_instruction

_append_instruction('You are helpful.', 'If you finished...')
# -> 'You are helpful.If you finished...'
  1. Or run a live session: a SequentialAgent with a single LlmAgent sub-agent whose instruction is 'You are helpful.', then call run_live. After the run starts, sub_agent.instruction is 'You are helpful.If you finished the user's request ...'.

Expected Behavior

The completion instruction starts its own paragraph:

You are helpful.\n\nIf you finished the user's request ...

Edge cases: an empty base instruction needs no separator ('' + suffix = suffix), and a base instruction that already ends with whitespace should not gain an extra blank line.

Observed Behavior

You are helpful.If you finished the user's request ... — no space, no newline between the two instructions. The same gluing happens for InstructionProvider (callable) instructions, since the provider path concatenates the resolved string the same way.

Environment Details

  • ADK Library Version (pip show google-adk): 2.15.0 (main @ 2b90353)
  • Desktop OS: Linux
  • Python Version (python -V): 3.12

Model Information

  • Are you using LiteLLM: No
  • Which model is being used: N/A (no model call is needed to reproduce; the instruction string is malformed before any model call)

Regression

Unknown — not checked against earlier releases.

How often has this issue occurred?

  • Always (100%)

Root Cause

_append_instruction in src/google/adk/agents/sequential_agent.py joins with plain + in both paths:

  • return instruction + suffix (plain str instruction)
  • return resolved + suffix (inside combined(), the InstructionProvider path)

Its only caller is SequentialAgent._run_live_impl, which appends the task_completed completion instruction. The codebase convention elsewhere is to separate instructions with a blank line — LlmRequest.append_instructions concatenates with \n\n — so the fix is to join the two parts with \n\n, skipping the separator when the base is empty or already ends with whitespace.

Additional Context

Two open PRs touch the same function but do not collide with this fix: #8285 ("keep live sequential completion tool off shared sub-agents") and #8286 ("keep the live task_completed out of the shared child agent", closes #8282) both only re-site the _append_instruction call to stop mutating shared sub-agent objects — neither changes how the two strings are joined. All three touch sequential_agent.py and test_sequential_agent.py, so whichever lands first, the others will need a rebase.

Minimal Reproduction Code

from google.adk.agents.sequential_agent import _append_instruction

assert _append_instruction('You are helpful.', 'If you finished...') == \
    'You are helpful.\n\nIf you finished...'  # fails on main: got 'You are helpful.If you finished...'
主要語言
Python
星號
22.3k
分支
4.4k
平均合併
1 天 2 小時
30 天內合併 PR
6

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。