Skip to content

[codex] Preserve live tool history#37

Merged
nick-pape merged 2 commits into
mainfrom
codex/live-tool-history
Jun 11, 2026
Merged

[codex] Preserve live tool history#37
nick-pape merged 2 commits into
mainfrom
codex/live-tool-history

Conversation

@nick-pape

Copy link
Copy Markdown
Owner

Summary

  • preserve assistant tool-call parts and tool result messages in active session model history
  • keep ACP tool updates and durable event shapes unchanged
  • add multi-turn coverage for successful and failed tool results

Closes #15.

Detailed validation

  • .\common\temp\pnpm-local\node_modules\.bin\pnpm.cmd --dir packages/agent-core test
  • .\common\temp\pnpm-local\node_modules\.bin\pnpm.cmd --dir packages/acp-agent test
  • node common/scripts/install-run-rush.js build
  • node common/scripts/install-run-rush.js test

@nick-pape nick-pape marked this pull request as ready for review June 11, 2026 18:05
Copilot AI review requested due to automatic review settings June 11, 2026 18:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the agent loop so that tool-call and tool-result information is preserved in the in-memory session.history across turns, allowing subsequent model turns to receive the same tool context that occurred earlier in the session. It also adds multi-turn test coverage to ensure tool history is included in later model requests.

Changes:

  • Record assistant tool-call parts and tool-result messages into session.history during streaming turns.
  • Split assistant history into (a) structured parts for tool calls and (b) trailing plain assistant text, while keeping durable event persistence unchanged.
  • Add multi-turn tests to assert that prior tool calls/results (success + failure) are included in later model turns.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/agent-core/src/agent.ts Adds tool-call/tool-result entries to session.history and helper logic to flush/append them during a turn.
packages/acp-agent/src/agent-prompt-cancellation.test.ts Adds regression tests asserting prior tool calls/results are present in later model turn messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/agent-core/src/agent.ts
Comment thread packages/agent-core/src/agent.ts
Comment thread packages/agent-core/src/agent.ts Outdated
@nick-pape nick-pape merged commit e2e8a8a into main Jun 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve tool calls and tool results in model history

2 participants