Skip to content

fix: pass clientTools to runEmbeddedAttempt in /v1/responses agent path - #52171

Merged
frankekn merged 6 commits into
openclaw:mainfrom
charzhou:fix/pass-client-tools-to-embedded-attempt
Mar 22, 2026
Merged

frankekn merged 6 commits into
openclaw:mainfrom
charzhou:fix/pass-client-tools-to-embedded-attempt

Conversation

@charzhou

Copy link
Copy Markdown
Contributor

Summary

  • Fix client-provided tools in /v1/responses requests being silently dropped when routing to an Agent (model: "agent:...")
  • runEmbeddedPiAgent() in run.ts calls runEmbeddedAttempt() by individually listing each param field but omitted clientTools, so params.clientTools in attempt.ts was always undefined
  • The downstream handling code (toClientToolDefinitions, allCustomTools merge, createAgentSession) was fully implemented but never triggered

Test plan

  • Send a /v1/responses request with tools field targeting an Agent and verify the Agent can see and invoke the client tools
  • Verify existing Agent behavior (built-in tools) is unaffected
  • Verify tool_choice filtering still works with client tools

@greptile-apps

greptile-apps Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent parameter-forwarding omission where clientTools (client-provided tools passed in /v1/responses requests targeting an agent:... model) were never reaching runEmbeddedAttempt. The fix is a single-line addition to the runEmbeddedPiAgent call-site that constructs the attempt params object — clientTools: params.clientTools was simply missing from the spread, while all downstream handling in attempt.ts (toClientToolDefinitions, allCustomTools merge, reserved-name deduplication) was already fully implemented and waiting for the value.

  • Root cause identified correctly: runEmbeddedAttempt was called with every param from RunEmbeddedPiAgentParams forwarded individually, but clientTools was silently skipped.
  • Fix is minimal and correct: one line added in the right place, consistent with how every other param is forwarded.
  • No new logic introduced: the existing downstream code in attempt.ts handles the now-populated clientTools exactly as intended.

Confidence Score: 5/5

  • Safe to merge — the fix is a one-line forwarding correction with no new logic, no behaviour change for existing callers, and all downstream handling was pre-validated.
  • The change is a trivial omission fix: one parameter was not forwarded through a long explicit object literal. All downstream code (attempt.ts) was already implemented and correct; this just connects the pipe. No risk of regression for paths that don't pass clientTools (the field is optional and defaults to undefined which is the previous behaviour).
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix: pass clientTools to runEmbeddedAtte..." | Re-trigger Greptile

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

Copy link
Copy Markdown
Contributor

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: 9a7cc2b086

ℹ️ 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 src/agents/pi-embedded-runner/run.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S and removed size: XS labels Mar 22, 2026

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

Copy link
Copy Markdown
Contributor

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: 0cca12c552

ℹ️ 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 src/agents/pi-embedded-runner/run.ts Resolved
Comment thread src/gateway/openresponses-http.ts Resolved

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

Copy link
Copy Markdown
Contributor

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: 850216fb11

ℹ️ 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 src/agents/pi-embedded-runner/run.ts Resolved
Comment thread src/gateway/openresponses-http.ts Resolved
@frankekn frankekn self-assigned this Mar 22, 2026
@frankekn
frankekn force-pushed the fix/pass-client-tools-to-embedded-attempt branch from c2e5c7f to db25854 Compare March 22, 2026 11:15

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

Copy link
Copy Markdown
Contributor

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: db25854f43

ℹ️ 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".

Comment thread src/gateway/openresponses-http.ts Resolved
@frankekn

Copy link
Copy Markdown
Contributor

@codex review

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

Copy link
Copy Markdown
Contributor

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: 1b66f53762

ℹ️ 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".

Comment on lines +539 to +540
const sessionKey = previousSessionKey ?? resolved.sessionKey;
const messageChannel = resolved.messageChannel;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Scope previous_response_id reuse to matching request context

This assignment always prioritizes the cached session from previous_response_id over the freshly resolved request context, so a request with a known response ID can bypass current user/session-key routing. In multi-user setups sharing one gateway token, that allows cross-conversation context bleed if a stale or leaked response ID is supplied; the cached entry should be validated against the same user/agent/session dimensions before reuse.

Useful? React with 👍 / 👎.

Comment thread src/gateway/openresponses-http.ts Outdated
Comment on lines +568 to +571
const responseId = `resp_${randomUUID()}`;
// Store responseId -> sessionKey so continuation turns via previous_response_id
// can resolve back to the same agent session.
storeResponseSession(responseId, sessionKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Start response-session TTL when response is emitted

The response/session mapping is stored before the agent run executes, but lookup expiry is based on this timestamp (30m TTL). If a response takes a long time (for example, long tool loops), the mapping may already be expired when the client receives the response.id, so an immediate previous_response_id continuation silently starts a new session and loses history. The timestamp should be recorded or refreshed when the response is actually returned.

Useful? React with 👍 / 👎.

@frankekn

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 👍

ℹ️ 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".

@frankekn
frankekn force-pushed the fix/pass-client-tools-to-embedded-attempt branch from 113a5bb to 0962ab6 Compare March 22, 2026 14:03
@frankekn
frankekn force-pushed the fix/pass-client-tools-to-embedded-attempt branch from 0962ab6 to 74519e7 Compare March 22, 2026 14:04
@frankekn
frankekn merged commit a07dcfd into openclaw:main Mar 22, 2026
8 checks passed
@frankekn

Copy link
Copy Markdown
Contributor

Merged via squash.

Thanks @charzhou!

MaheshBhushan pushed a commit to MaheshBhushan/openclaw that referenced this pull request Mar 22, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
frankekn added a commit to artwalker/openclaw that referenced this pull request Mar 23, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
furaul pushed a commit to furaul/openclaw that referenced this pull request Mar 24, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
@charzhou
charzhou deleted the fix/pass-client-tools-to-embedded-attempt branch April 11, 2026 16:50
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…th (openclaw#52171)

Merged via squash.

Prepared head SHA: 74519e7
Co-authored-by: CharZhou <[email protected]>
Co-authored-by: frankekn <[email protected]>
Reviewed-by: @frankekn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants