Skip to content

Fix JSON serialization of contexts in external postprocessors - #138

Merged
arnaugrispg merged 2 commits into
mainfrom
serialize-external-request
Sep 15, 2026
Merged

arnaugrispg merged 2 commits into
mainfrom
serialize-external-request

Conversation

@arnaugrispg

Copy link
Copy Markdown
Contributor

Summary

Fixes the external postprocessor when context: true is configured.

memory.contexts contains Pydantic Context instances. Passing them directly to HTTPX through json= caused request construction to fail with:

TypeError: Object of type Context is not JSON serializable

Each context is now converted to a JSON-compatible dictionary using model_dump(mode="json") before building the external request.

Testing

  • Added a regression test using a real Context instance.
  • Confirmed the test reproduced the serialization error before the fix.
  • Verified that the request body is valid JSON after the fix.
  • Ran the complete external-agent test file.

@arnaugrispg
arnaugrispg requested a review from a team September 15, 2026 06:43
@arnaugrispg
arnaugrispg added this pull request to the merge queue Sep 15, 2026
Merged via the queue into main with commit 7ae0a78 Sep 15, 2026
4 checks passed
@arnaugrispg
arnaugrispg deleted the serialize-external-request branch September 15, 2026 07:14
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.

2 participants