Skip to content

Commit fbf5286

Browse files
hypxtmcSoulter
andauthored
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 <[email protected]> Co-authored-by: Soulter <[email protected]>
1 parent 2b6b31a commit fbf5286

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎astrbot/core/star/context.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from deprecated import deprecated
99

1010
from astrbot.core.agent.hooks import BaseAgentRunHooks
11-
from astrbot.core.agent.message import Message
11+
from astrbot.core.agent.message import ContentPart, Message
1212
from astrbot.core.agent.runners.tool_loop_agent_runner import ToolLoopAgentRunner
1313
from astrbot.core.agent.tool import ToolSet
1414
from astrbot.core.astrbot_config_mgr import AstrBotConfigManager
@@ -220,6 +220,7 @@ async def tool_loop_agent(
220220
prompt: str | None = None,
221221
image_urls: list[str] | None = None,
222222
audio_urls: list[str] | None = None,
223+
extra_user_content_parts: list[ContentPart] | None = None,
223224
tools: ToolSet | None = None,
224225
system_prompt: str | None = None,
225226
contexts: list[Message] | None = None,
@@ -237,6 +238,7 @@ async def tool_loop_agent(
237238
prompt: The prompt to send to the LLM, if `contexts` and `prompt` are both provided, `prompt` will be appended as the last user message
238239
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
239240
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
241+
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()`)
240242
tools: ToolSet of tools available to the LLM
241243
system_prompt: System prompt to guide the LLM's behavior, if provided, it will always insert as the first system message in the context
242244
contexts: context messages for the LLM
@@ -285,6 +287,7 @@ async def tool_loop_agent(
285287
prompt=prompt,
286288
image_urls=image_urls or [],
287289
audio_urls=audio_urls or [],
290+
extra_user_content_parts=extra_user_content_parts or [],
288291
func_tool=tools,
289292
contexts=context_,
290293
system_prompt=system_prompt or "",

0 commit comments

Comments
 (0)