feat: forward extra_user_content_parts through Context.tool_loop_agent (#10237)

* feat: forward extra_user_content_parts through Context.tool_loop_agent

Context.tool_loop_agent() builds ProviderRequest without extra_user_content_parts, so plugins starting a subagent through this entry point cannot inject per-turn content that must not be persisted into the conversation history. ToolLoopAgentRunner already reads the field and the main agent flow uses it extensively; only this entry point lacked the plumbing. Runtime behaviour is unchanged when the parameter is omitted.

Refs #10230

* Delete tests/test_star_context_extra_user_content_parts.py

---------

Co-authored-by: hypxtmc <179467837+hypxtmc@users.noreply.github.com>
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
This commit is contained in:
hypxtmc
2026-09-27 11:06:55 +08:00
committed by GitHub
co-authored by hypxtmc Soulter
parent 2b6b31a013
commit fbf5286c3b
+4 -1
View File
@@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, Protocol
from deprecated import deprecated
from astrbot.core.agent.hooks import BaseAgentRunHooks
from astrbot.core.agent.message import Message
from astrbot.core.agent.message import ContentPart, Message
from astrbot.core.agent.runners.tool_loop_agent_runner import ToolLoopAgentRunner
from astrbot.core.agent.tool import ToolSet
from astrbot.core.astrbot_config_mgr import AstrBotConfigManager
@@ -220,6 +220,7 @@ class Context:
prompt: str | None = None,
image_urls: list[str] | None = None,
audio_urls: list[str] | None = None,
extra_user_content_parts: list[ContentPart] | None = None,
tools: ToolSet | None = None,
system_prompt: str | None = None,
contexts: list[Message] | None = None,
@@ -237,6 +238,7 @@ class Context:
prompt: The prompt to send to the LLM, if `contexts` and `prompt` are both provided, `prompt` will be appended as the last user message
image_urls: List of image URLs to include in the prompt, if `contexts` and `prompt` are both provided, `image_urls` will be appended to the last user message
audio_urls: List of audio URLs or local paths to include in the prompt, if `contexts` and `prompt` are both provided, `audio_urls` will be appended to the last user message
extra_user_content_parts: Extra content parts appended to the user message. Use this for per-turn context that must not be persisted into the conversation history (e.g. `TextPart(text=...).mark_as_temp()`)
tools: ToolSet of tools available to the LLM
system_prompt: System prompt to guide the LLM's behavior, if provided, it will always insert as the first system message in the context
contexts: context messages for the LLM
@@ -285,6 +287,7 @@ class Context:
prompt=prompt,
image_urls=image_urls or [],
audio_urls=audio_urls or [],
extra_user_content_parts=extra_user_content_parts or [],
func_tool=tools,
contexts=context_,
system_prompt=system_prompt or "",