Does livekit agents remove `\n` charecter in the i...
# agents
m
Does livekit agents remove
\n
charecter in the instructions? I do an api call to get the instructions to for the livekit agent. The instructions are in markdown format. It has
\n
charecters for new lines. But when I use it in livekit agents and look at the openai platform logs, all new lines have disappeared. It is just one long line of instructions. In contrast, the chatbot I have with same instructions show proper newlines and markdown formatting in openai platform logs.
l
It wouldn't surprise me, but would you expect adding
\n
to the instructions would influence the LLM behaviour?
m
My chat agent with proper markdown formatting instructions follows the instructions better than the voice agent. Livekit Agent strips out
\n
causing markdown format issues
l
I tried modifying https://github.com/livekit-examples/python-agents-examples/blob/main/basics/listen_and_respond.py to add
Copy code
async def llm_node(self, chat_ctx, tools, model_settings):  
        # Log the input chat context  
        logger.info(f"LLM Input: {chat_ctx.to_dict()}")  
        
        # Insert custom preprocessing here
        async for chunk in Agent.default.llm_node(self, chat_ctx, tools, model_settings):
            # Insert custom postprocessing here
            yield chunk
Based on https://docs.livekit.io/agents/build/nodes/#llm_node. With instructions as
Copy code
instructions="""
                You are a helpful agent. 
                When the user speaks, you listen and respond.
            """,
I see output:
Copy code
2025-11-05 10:36:37,236 - INFO listen-and-respond - LLM Input: {'items': [{'id': 'lk.agent_task.instructions', 'type': 'message', 'role': 'system', 'content': ['\n                You are a helpful agent. \n                When the user speaks, you listen and respond.\n            '], 'interrupted': False}]}
So, it looks like the new lines are being passed in in this example?
m
Did you use openai llm? can you check the logs in openai platform dashboard? my logs in openai dashboard do not have \n charecters