Skip to content

fix(invocation): preserve JSON across agent calls and history - #828

Draft
WH-2099 wants to merge 3 commits into
mainfrom
fix/preserve-backwards-json
Draft

WH-2099 wants to merge 3 commits into
mainfrom
fix/preserve-backwards-json

Conversation

@WH-2099

@WH-2099 WH-2099 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #827.

Backwards calls reject object-valued replay state and corrupt some JSON values, while ordinary plugin dispatch and Agent responses round integers above 2^53.
Preserve JSON through both directions of invocation so a tool argument such as 9007199254740993 reaches the tool unchanged and survives saved Agent history.

Keep backwards request values as json.RawMessage until typed dispatch, then decode with UseNumber and the existing validator across all 17 invocation types.
Apply number-preserving decoding to InvokePluginRequest and ToolResponseChunk as well.
Agent blob assembly reads the resulting numeric length and rejects negative, fractional, overflowing, or oversized values before allocation.

Trusted tenant/user/type injection still overrides case-folded input aliases.
Null or omitted message content is accepted where the SDK permits it, including tool-only responses, while invalid content types remain rejected.
The serverless missing-session path reads only the request ID to preserve error correlation.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Performance improvement
  • Other

Essential Checklist

  • Tested locally.
  • Added meaningful regressions and confirmed they pass.
  • Linked the related issue using GitHub closing syntax.

Validation

  • go test -timeout 1m ./cmd/... ./internal/... ./pkg/... passed with isolated PostgreSQL/Redis instances and temporary CI test keys.
  • Race checks passed for backwards invocation, transaction handling, Dify calls, model entities, JSON parsing, plugin dispatch, and Agent responses.
  • Focused go vet passed.
  • Whole-repository go vet still reports the existing stopRenew context leak in unchanged internal/core/control_panel/launcher_local.go.
  • New regressions exercise real Gin binding, request conversion, generic plugin invocation, all three runtime types, saved history, and blob assembly.
  • A controlled local deployment of the actual Dify API, daemon, SDK, official Anthropic/OpenAI providers, and Agent plugins passed two-tool continuations and PostgreSQL history restoration over TCP and serverless HTTP.

This is part of the joint next-version upgrade with SDK #390, official plugins #4034, and #4035.
The host work is Dify #44502.
Final release versions and its Graphon dependency publication remain pending.
Live vendor APIs and production deployment were not tested.

@WH-2099 WH-2099 changed the title fix(invocation): preserve JSON in backwards requests fix(invocation): preserve JSON across agent calls and history Oct 21, 2026

This branch has not been deployed

No deployments
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.

fix(invocation): preserve opaque JSON and integer precision in backwards requests

1 participant