- Notifications
You must be signed in to change notification settings - Fork1k
Open
Description
Question
Hi, I was migrating my old composer implementation tohistory_processors
based composer and found that I couldn't save the results processed byhistory_processors
, which resulted in each tool return triggering the compact.
I'm now implementing this using a rather tricky way: transfer viactx
with apatched_messages
field
ctx=AgentContext()asyncwithagent.iter(...,deps=ctx)asrun:asyncfornodeinrun:ifAgent.is_user_prompt_node(node)orAgent.is_end_node(node):continueelifAgent.is_model_request_node(node)orAgent.is_call_tools_node(node):asyncwithnode.stream(run.ctx)asrequest_stream:# Right after request, save immediatelyrun.ctx.state.message_history=ctx.patched_messagesifctx.patched_messageselse ...# Then start streamingasyncforeventinrequest_stream: ...
Releated
- feat: add
history_processors
parameter toAgent
for message processing #1970 - feat: add RunContext support to history processors #2002
What do you think? I intuit thathistory_processors
will change message history.
cc@Kludex
Additional Context
No response