Skip to content

[rollout] fix: prompt2text decoding for SingleTurnAgentLoop#5277

Open
jnash10 wants to merge 1 commit intoverl-project:mainfrom
jnash10:jnash10-patch-singleTurn-rolloutTrace
Open

[rollout] fix: prompt2text decoding for SingleTurnAgentLoop#5277
jnash10 wants to merge 1 commit intoverl-project:mainfrom
jnash10:jnash10-patch-singleTurn-rolloutTrace

Conversation

@jnash10
Copy link

@jnash10 jnash10 commented Feb 11, 2026

Fixes #5276

What does this PR do?

Fixes prompt IDs not being decoded for SingleTurnAgentLoop. Issue was the single agent loop lacked the rollout_trace_op decorator.

Patch: Add Weave Tracing to SingleTurnAgentLoop

Summary

Add @rollout_trace_op decorator to SingleTurnAgentLoop.run() to enable Weave tracing with token2text support.

Problem

When using SingleTurnAgentLoop (the default agent), Weave traces only show AsyncLLMServerManager.generate calls. The token2text=True option doesn't add prompt_text and response_text fields to the trace output.

Screenshot 2026-02-10 142923

This happens because SingleTurnAgentLoop.run() lacks the @rollout_trace_op decorator that ToolAgentLoop.run() has.

Component Has @rollout_trace_op?
ToolAgentLoop.run Yes
SingleTurnAgentLoop.run No (missing)
AsyncLLMServerManager.generate Yes

Solution

Add the @rollout_trace_op decorator to SingleTurnAgentLoop.run().

File Changed

verl/experimental/agent_loop/single_turn_agent_loop.py

Diff

 from verl.experimental.agent_loop.agent_loop import AgentLoopBase, AgentLoopOutput, register
 from verl.tools.utils.tool_registry import initialize_tools_from_config
 from verl.utils.profiler import simple_timer
+from verl.utils.rollout_trace import rollout_trace_op

 logger = logging.getLogger(__file__)
 logger.setLevel(os.getenv("VERL_LOGGING_LEVEL", "WARN"))
@@ -40,6 +41,7 @@ class SingleTurnAgentLoop(AgentLoopBase):
         tool_list = initialize_tools_from_config(tool_config_path) if tool_config_path else []
         self.tool_schemas = [tool.tool_schema.model_dump(exclude_unset=True, exclude_none=True) for tool in tool_list]

+    @rollout_trace_op
     async def run(self, sampling_params: dict[str, Any], **kwargs) -> AgentLoopOutput:
         messages = list(kwargs["raw_prompt"])

Why This Works

SingleTurnAgentLoop.run() already returns AgentLoopOutput with the required fields:

  • prompt_ids (line 71)
  • response_ids (line 72)

The add_token2text function in rollout_trace.py checks for these exact fields. Once the method is decorated and traced, token2text=True correctly adds prompt_text and response_text to the output.

Result

After this patch:

  • SingleTurnAgentLoop.run appears as parent traces in Weave (matching ToolAgentLoop behavior)
  • token2text=True adds prompt_text and response_text fields
  • AsyncLLMServerManager.generate appears as nested child traces
Screenshot 2026-02-11 083010

Fixes prompt IDs not being decoded in a single turn agent.
Issue was the single agent loop lacked the `rollout_trace_op` decorator.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly enables Weave tracing for SingleTurnAgentLoop by adding the @rollout_trace_op decorator to its run method. This change aligns its behavior with ToolAgentLoop and fixes the issue where prompt and response text were not being decoded in traces when token2text=True. The implementation is straightforward and correct. I have reviewed the changes and have not identified any issues.

@wuxibin89
Copy link
Collaborator

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.

Prompt token IDs not decoded for single turn agent in weave traces

2 participants