agents icon indicating copy to clipboard operation
agents copied to clipboard

Returning a plain response from onChatMessage triggers nothing with no error messages

Open jcheese1 opened this issue 10 months ago • 3 comments

I have this in onChatMessage:

   const lastMessage = this.messages.slice(-1);

    if (lastMessage[0].content === "hardcoded") {
      return new Response("hello");
    }

// stream response

This does not trigger anything with no errors visible

jcheese1 avatar Mar 25 '25 00:03 jcheese1

Hmm, we should make this experience better...

threepointone avatar Mar 30 '25 14:03 threepointone

hey @threepointone !

I am trying to implement agents but without streaming - is it currently possible with agents-sdk? current way of doing is hacking around onChatMessage like this:

return new Response(0:"${agentResp.response}"\n);

but I still have to call onFinish somewhere or else the message won't persist, so kinda hardcoding the params.

FYI I'm doing this because I am generating the response as a part of a structured output - AFAIK theres no way to stream that?

ex.

experimental_output: Output.object({
  schema: z.object({
    response: z.string(),  // this is the response that gets returned back to the us
    emotionReasoning: z.string(), // these get stored in DB
    emotion: z.string(),
  })
});

jcheese1 avatar Apr 10 '25 00:04 jcheese1

@jcheese1 this has been amended, you will have a proper message now, let me know if we are good to close it

whoiskatrin avatar Jun 04 '25 20:06 whoiskatrin