Skip to content

Add terminating tool results and defineTool helper#832

Open
HabibPro1999 wants to merge 3 commits intocan1357:mainfrom
HabibPro1999:feat/pi-runtime-harness
Open

Add terminating tool results and defineTool helper#832
HabibPro1999 wants to merge 3 commits intocan1357:mainfrom
HabibPro1999:feat/pi-runtime-harness

Conversation

@HabibPro1999
Copy link
Copy Markdown
Contributor

@HabibPro1999 HabibPro1999 commented Apr 27, 2026

What

  • Add terminate?: boolean support to tool results/messages.
  • Suppress only the automatic model continuation when every finalized tool result in a batch terminates.
  • Preserve queued Agent.followUp() handling after terminating tool batches.
  • Add the typed extension SDK defineTool() identity helper.
  • Update changelogs for the user-facing API additions.

Why

This ports two small Pi runtime-harness improvements to OMP:

  • deterministic tools such as approval/yield/final-answer style tools can end the current turn without an unnecessary follow-up LLM call
  • extension authors get a typed helper for custom tool definitions and Pi-style examples

Part of the Pi runtime/agentic harness migration stack.

Testing

  • bun test packages/agent/test/agent.test.ts packages/coding-agent/test/extensions-runner.test.ts
  • bunx biome check on all files changed by this PR
  • Earlier pre-rebase checks: bun run check:ts and PATH="$HOME/.cargo/bin:$PATH" bun run check

Known caveat after rebasing onto latest main: full bun run check:ts is currently blocked by unrelated Biome formatting/import-order issues already present in origin/main files not touched by this PR (line-hash.ts, tools/renderers.ts, tools.test.ts, tools/search-renderer.test.ts).


  • bun check passes (blocked after latest main rebase by unrelated upstream Biome issues listed above)
  • Tested locally
  • CHANGELOG updated (if user-facing)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 887b4f4f58

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent/src/agent-loop.ts Outdated
Comment on lines 297 to 299
if (shouldTerminateTurn) {
break;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep follow-up queue processing after terminate batches

Breaking out of the outer loop here skips the getFollowUpMessages() check entirely when all tool results in a tool-use batch have terminate: true. That regresses the Agent.followUp() contract (“processed after the agent finishes”): follow-up messages queued while streaming can remain stuck in the queue with no automatic delivery, because the run ends before the follow-up dequeue path is reached. This shows up when a terminating deterministic tool finishes and the user (or session code) has already queued follow-up input during that same run.

Useful? React with 👍 / 👎.

@HabibPro1999
Copy link
Copy Markdown
Contributor Author

Addressed the Codex follow-up review in 4c0f8ab.

Terminating tool batches now suppress only the automatic model continuation; they still fall through to the normal follow-up dequeue path so queued Agent.followUp() messages are delivered.

Added regression coverage for a follow-up queued during a terminating tool execution.

Verification:

  • bun test packages/agent/test/agent.test.ts — 15 pass
  • bun run check:ts — pass

@HabibPro1999 HabibPro1999 force-pushed the feat/pi-runtime-harness branch from 4c0f8ab to e6dc98e Compare April 28, 2026 09:56
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.

1 participant