Skip to content

Store a plain JSON copy of tool outputs that carry functions - #1642

Merged
helpcodeai merged 2 commits into
mainfrom
fix/audit-non-json-output
Nov 12, 2026
Merged

helpcodeai merged 2 commits into
mainfrom
fix/audit-non-json-output

Conversation

@helpcodeai

Copy link
Copy Markdown
Contributor

Summary

On 11-11 at 06:51 UTC a hand-made Postgres connector's execute_query succeeded, but its tool-call log row was lost: Prisma refused it with Invalid value for argument toPostgres: We could not serialize [object Function]. A value in the result carried a toPostgres method. boundPayload measures the output with JSON.stringify, which drops functions silently, and then returned the original object (same reference) for Prisma to store.

boundPayload now notices functions (and symbols) while it serializes, through the replacer it already runs, and continues with the plain JSON copy. Outputs without them are unchanged and keep the same reference.

Changes

  • audit/bound-payload.ts: flag functions/symbols during JSON.stringify; when found, work on JSON.parse(json), for both the small path and the truncated excerpt.
  • audit/bound-payload.spec.ts: a row with a toPostgres function comes back as plain JSON, small and truncated.

Type

  • Bug fix

Testing

  • Added/updated unit tests
  • npx jest src/audit/bound-payload.spec.ts in packages/backend: 8/8. npx eslint on both files clean. Full checks in CI.

Same in Cloud and self-hosted. No schema change, nothing in ee/.

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • All existing tests pass (npm test) (CI)
  • This PR has a descriptive title

@helpcodeai
helpcodeai merged commit 8e52ac1 into main Nov 12, 2026
16 checks passed
@helpcodeai
helpcodeai deleted the fix/audit-non-json-output branch November 12, 2026 08:59
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 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.

1 participant