The generate_reply in agents 1.x does not properly...
# agents
c
The generate_reply in agents 1.x does not properly take into the chat context. There is a bug in your agents codebase @refined-appointment-81829 No matter what prompt I give it always just repeats the last message. I even pu tstuff like generate_reply(instruction=“Say hi.“) and no matter where in the conversation it never follows this… it always repeats the last thing it said.
j
what LLM are you using? I cannot reproduce the issue with gpt-4o-mini. Also, the instructions of
generate_reply
is added after the system message on the top of the chat ctx, so it might be ignored if you have a long chat ctx.
c
Oh… so it doesn’t actually take in the whole chat context? That’s really imortant for me. I use gpt 4.1. How can I get it to use the whole chat context?
I’m hoping to replicate the same functionality as forcing an LLM turn and just saying what it responds. How can I do this? Seems this is not what generate reply does @jolly-air-155
j
no I mean it takes the whole chat ctx, but the instructions are added to the system message on the top
can you share a minimal example that can reproduce the issue?
c
Here’s one:
Copy code
@ctx.room.on("sip_dtmf_received")
    def dtmf_received(dtmf: rtc.SipDTMF):
logging.info`(f"DTMF received from {dtmf.participant.identity}: {dtmf.code} / {dtmf.digit}") handle = ctx.proc.userdata["session"].generate_reply( instructions=(f"(The Contact has just dialed the digit {dtmf.digit} (which is DTMF code {dtmf.code}) via their phone pad.Based on this, you would:)") )` this is my code to receive dtmf tones . the Agent does receive dtmf tones but the generate_reply just makes the agent repeat itelf and not like say anything regarding those dtmf tones.
And when the agent starts you say “ok I’m going to dial some digits you just repeat back to me what I dialed”
And then you dial the drmf tones but the generate_reply ignores the user message and chat context and just repeats itself as if there was no chat context on top of the system message. What the system message here is doesn’t matter. It just doesn’t follow the user message or chat context.
I think maybe the issue is it adds the instructions to the system message instead of at the end of the most recent message. But if I use user_input, it shows as if the user is talking which is not what I want either.
how do I simply just get the LLM to generate a response as if the user said something and speak that out but not have it get persisted in the chat context? @jolly-air-155
j
I don’t think it’s supported by
generate_reply
right now, but you can use
llm.chat
to generate the reply directly and use a
session.say
with
add_to_chat_ctx=False
to speak the reply
👍 1
c
Oh I didn’t realize LLM.chat still existed in agents 1.x. I couldn’t find it in the documentation for 1.x
Huh. The docs are still not clear. Can you please give me an example of how to actually use llm.chat? @jolly-air-155
j
llm.chat
is still there if you can access the llm instance, or you can use
llm_node
from agent.
👍 1