agent-lightning icon indicating copy to clipboard operation
agent-lightning copied to clipboard

Warning: Length of triplets is 0 for rollout

Open MYXjason opened this issue 4 months ago • 5 comments

Hi. I wrote a client script based on the Agno framework by following the RAG example. I defined a custom reward function and added @reward, the return value of training_rollout_async only contains the reward. When I started the server, the following warning appeared: “ Warning: Length of triplets is 0 for rollout ”. After printing the related information, I found that the triplet_exporter cannot effectively extract triplets from the tracer, so the value of triplet becomes an empty array. I would like to know how to resolve the issue of the triplet being an empty array. Could you provide an example of an agent returning a Rollout type? I tried defining a custom Rollout return value myself, but it still automatically extracts triplets from the trace.

MYXjason avatar Aug 27 '25 10:08 MYXjason

If the rollout returns a Rollout object, I think the auto traced information would be suppressed.

https://github.com/microsoft/agent-lightning/blob/d00cc3e4aab227207520c080e30003c5597a988c/agentlightning/litagent.py#L117

There is currently no dummy tracer that does nothing. You may implement one on your own.

The length 0 problem is usually related to no LLM calls being monitored. Have you ever called OpenAI chat completion API?

ultmaster avatar Aug 27 '25 23:08 ultmaster

Sorry for the late reply. I use the Agno framework to call local models, which is compatible with the OpenAI API. I monitored the communication between the client and the server using Socket, and found that the spans generated by Agno do not contain the field openai.chat.completion (i.e., llm_call_match: str = r"openai.chat.completion"), nor do they include a request_id. However, they do contain input, output, and reward information.

Without these fields, the TripletExporter seems unable to extract triplets from the trace. I designed a custom TripletExporter to extract triplets, and although prompt_token_ids and response_token_ids were assumed to be random data, it was able to train. Later, when I switched to the openai-agent framework, this issue did not occur. I think the reason is that the spans generated by Agno do not match the AgentLightning framework.

MYXjason avatar Sep 02 '25 01:09 MYXjason

Additionally, to facilitate testing, the prompt_token_ids and response_token_ids in the custom triplet extractor were assigned random values. Theoretically, these should instead be derived from the tokenizer of the local model.

MYXjason avatar Sep 02 '25 01:09 MYXjason

It sounds good.

One problem though. I recommend using the exact same tokens that the inference engine of the model used in prompt consumption and response generation. Retokenization of the strings can be problematic in many cases and could lead to suboptimal performance.

ultmaster avatar Sep 02 '25 08:09 ultmaster

Thank you for your feedback. This is a really great project, and I hope examples for Agno can be provided later on.

MYXjason avatar Sep 02 '25 12:09 MYXjason