Fix agent event ordering: update state before emitting events

Previously, Agent.emit() was called before state was updated (e.g., appendMessage).
This meant event handlers saw stale state - when message_end fired,
agent.state.messages didn't include the message yet.

Now state is updated first, then events are emitted, so handlers see
consistent state that matches the event.
This commit is contained in:
Mario Zechner 2025-12-09 14:33:39 +01:00
parent 1194fb8afa
commit 2b0aa5ed8e
4 changed files with 321 additions and 659 deletions

View file

@ -1,22 +1,8 @@
{
"folders": [
{
"name": "sitegeist",
"path": "../sitegeist"
},
{
"name": "pi-mono",
"path": "."
},
{
"name": "mini-lit",
"path": "../mini-lit"
},
{
"path": "../../agent-tools/browser-tools"
},
{
"path": "../pi-terminal-bench"
}
],
"settings": {}