Skip to content

fix(agentstudio): preserve tool configuration round-trip - #304

Open
leonardocuco wants to merge 4 commits into
mainfrom
feat/cec-1883-agent-tool-payload
Open

leonardocuco wants to merge 4 commits into
mainfrom
feat/cec-1883-agent-tool-payload

Conversation

@leonardocuco

@leonardocuco leonardocuco commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Agent create/update payloads containing algolia_compare_products can lose tool fields such as description when the pinned Go SDK decodes and re-encodes a variant it does not yet model. The same SDK decoding also drops the description from agents get output, even when the API stored it correctly.

Change

  • Preserve the explicitly supplied tools value when sending agents create and agents update, including --json, --file and stdin. The API remains responsible for validating tools.
  • Preserve the API's tools payload in agents get JSON and JSONPath output while retaining SDK handling for other response fields and API errors.
  • Cover explicit, omitted, null and empty tool values, unrelated fields, JSONPath compatibility, API errors and invalid JSON.

This targets a confirmed tool-configuration gap; it does not assert parity for all agent fields. The SDK may expose an API error message that itself reflects a secret; this PR does not establish general error redaction.

Verification

  • go test ./...
  • go build ./...
  • gofumpt and git diff --check
  • Mocked HTTP tests cover create/update and get, including the response description lost by the current SDK.

Related to CEC-1883 (C4). Draft during code freeze; no release or deployment. The new read-path fix has not yet been validated against a running backend.

@leonardocuco

Copy link
Copy Markdown
Contributor Author

Claude Code reviewed this change at 509e33a for the author: 7 findings, 0 fixed. All are minor or pre-existing, so nothing was pushed.

  • pkg/cmd/agents/update/update.go:111 (and create.go:112): the raw tools key is matched case-sensitively, while the typed decode is not, so a payload with "Tools" skips the pass-through. Left: unusual input, the API field is lowercase tools.
  • pkg/cmd/agents/update/update.go:111: only tools is passed through verbatim, other unmodeled keys are still dropped by the SDK structs. Left: pre-existing, and the change targets the one confirmed gap.
  • pkg/cmd/agents/update/update.go:138: with tools present, the SDK merge re-decodes config numbers as float64, so integers above 2^53 could lose precision. Left: no realistic config value is that large.
  • pkg/cmd/agents/create/create.go:90: build functions set opts.RawTools as a side channel. Left: it is reset at the top of each call, so it is correct today.
  • pkg/cmd/agents/update/update.go:111: the raw-tools extraction is duplicated in create and update. Left: a shared helper is a refactor for the author to weigh.
  • pkg/cmd/agents/update/update.go:143: the UpdateAgent call is long. Left: lint passes on this head.
  • pkg/cmd/agents/create/create.go:112: a literal "tools": null is now forwarded instead of ignored. Left with the author: whether null should mean omit or clear is a product decision.

Checks on this head are green.

@leonardocuco
leonardocuco marked this pull request as ready for review December 1, 2026 10:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T11:06:49.502697Z f0659f8 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@leonardocuco
leonardocuco marked this pull request as draft December 1, 2026 10:57
@leonardocuco leonardocuco changed the title fix(agentstudio): preserve tool configuration payloads fix(agentstudio): preserve tool configuration round-trip Dec 1, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@leonardocuco

Copy link
Copy Markdown
Contributor Author

Claude Code reviewed this change at 34aabb7 for the author: 8 findings, 0 fixed, all left for the author. Separately, the lint failure (stylecheck initialism names) is fixed in f0659f8.

  • pkg/cmd/agents/get/get.go:122: JSONPath on nullable scalar fields (description, lastUsedAt and similar) probably prints the SDK wrapper struct instead of the value. This is not caused by this change, since the SDK type printed the same way before. Left: needs a decision on unwrapping the nullable values, plus tests.
  • pkg/cmd/agents/get/get.go:95: only tools comes from the raw body; other fields the SDK does not model are dropped and absent ones can print as null. Left: widening the raw-body approach goes beyond the tool-payload scope in the description.
  • pkg/cmd/agents/get/get.go:91: the strict typed decode still runs first and can fail the command on shapes the SDK rejects. Left: same scope question.
  • pkg/cmd/agents/get/get.go:117: tools numbers decode as json.Number while config numbers are float64, so numeric JSONPath filters differ between them. Left: minor.
  • pkg/cmd/agents/create/create.go:153: create, update, list and publish still print the typed response, so tool descriptions are not echoed back there. Left: depends on the same shared-helper decision.
  • pkg/cmd/agents/get/get.go:158: the error decoder copies SDK logic into the command. Left: would move to a shared helper if the scope is widened.
  • pkg/cmd/agents/get/get.go:135: struct fields are typed any where concrete types would do. Left: minor.
  • pkg/cmd/agents/get/get.go:87: an empty 2xx body prints null and exits 0. Left: minor.

@leonardocuco
leonardocuco marked this pull request as ready for review December 1, 2026 11:05

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0659f87e0

ℹ️ 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 pkg/cmd/agents/get/get.go Resolved
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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