Skip to content

feat(weave_ts): accept JSON tool values - #7702

Merged
rgao-coreweave merged 3 commits into
masterfrom
rgao/weave-ts-tool-results
Aug 7, 2026
Merged

feat(weave_ts): accept JSON tool values#7702
rgao-coreweave merged 3 commits into
masterfrom
rgao/weave-ts-tool-results

Conversation

@rgao-coreweave

@rgao-coreweave rgao-coreweave commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add exported JsonValue and JsonObject types for JSON-compatible tool data
  • accept a JSON object or pre-serialized string in ToolInit.args
  • accept a JSON value in Tool.end({result}) and serialize structured values inside the SDK
  • record result, error, and errorType together when a tool ends
  • preserve string arguments/results and deprecated mutable Tool.result compatibility

Testing

  • pnpm exec jest --runInBand src/__tests__/genai (9 suites, 101 tests, 13 snapshots)
  • pnpm exec jest --runInBand src/__tests__/genai/tool.test.ts (8 tests)
  • pnpm run typecheck:cjs
  • pnpm run typecheck:esm
  • pnpm run lint
  • pnpm run prettier-check

Breaking changes

None. Existing string arguments and mutable Tool.result assignments continue to work.

Related

@rgao-coreweave
rgao-coreweave requested review from a team as code owners August 6, 2026 22:26
@rgao-coreweave
rgao-coreweave marked this pull request as draft August 6, 2026 22:29
@rgao-coreweave rgao-coreweave changed the title feat(weave_ts): accept structured tool values feat(weave_ts): accept JSON tool values Aug 6, 2026
if (typeof value === 'string') {
return value;
}
try {

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.

I see the PR is draft, so apologies if it is too early to ask and if this is something you had in mind already.

Is there anything that prevents a tool argument or result containing a secret or customer data from being serialized into these span attributes in prod?

Should we make content capture opt-in or redact it before recording?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, marking the PR ready for review.

Good call out that we should add pii redaction to the tool args. However I don't think we have this capability to do so in typescript yet.

@rgao-coreweave
rgao-coreweave marked this pull request as ready for review August 6, 2026 23:01
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@rgao-coreweave
rgao-coreweave merged commit 76d9014 into master Aug 7, 2026
108 checks passed
@rgao-coreweave
rgao-coreweave deleted the rgao/weave-ts-tool-results branch August 7, 2026 16:11
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants