Conversation
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
🦋 Changeset detectedLatest commit: e075841 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
Co-authored-by: Brian Yin <toubatbrian@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69c25151bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (content) { | ||
| return [attrsStr ? `<${tagName} ${attrsStr}>` : `<${tagName}>`, content, `</${tagName}>`].join( | ||
| '\n', |
There was a problem hiding this comment.
Escape XML entities before serializing summary input
_summarize() now tells the model the history is XML, but toXml() interpolates raw message/tool text directly into tags, so any content containing <, &, or </...> will produce malformed XML and can change how the summarizer interprets prior turns. This can silently corrupt summaries for common inputs like HTML/XML tool outputs or user text with angle brackets; escaping XML entities in tag bodies (and attributes) is needed to keep the structure faithful.
Useful? React with 👍 / 👎.
Description
Port livekit/agents PR #5099 into agents-js by making history summarization action-aware. The summarizer now consumes tool call and tool result items, and TaskGroup preserves child task tool execution history so those results can be distilled into summaries. This also adds a reusable
llm.formatChatHistory(...)helper for readable chat-context logging.Changes Made
ChatContext._summarize()to split the history over the full chat item stream, render messages/tool calls/tool outputs as XML, and emit XML summary messagesTaskGroupsummarization to keep the full chat history needed for action-aware summaries by re-merging completed child task contexts after the standard AgentTask handoffllm.formatChatHistory(chatCtx, options?)to render messages, tool calls, tool outputs, and handoffs into a readable multiline debug/log stringPre-Review Checklist
Testing
Automated tests added/updated (if applicable)
All tests pass
Make sure both
restaurant_agent.tsandrealtime_agent.tswork properly (for major changes)pnpm build:agentspnpm exec vitest run agents/src/llm/chat_context.test.ts examples/src/testing/task_group.test.tspnpm exec vitest run agents/src/llm/utils.test.tsAdditional Notes
This restores the TaskGroup-specific re-merge so action-aware summarization also sees child task tool calls and tool outputs end to end, and adds a small formatter utility for logging/debugging chat histories.
Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.