Skip to content

fix(chat_history): support nested multimodal content - #209

Merged
Eigenwise merged 4 commits into
mainfrom
fix/nested-multimodal-chat-history
Feb 14, 2026
Merged

fix(chat_history): support nested multimodal content#209
Eigenwise merged 4 commits into
mainfrom
fix/nested-multimodal-chat-history

Conversation

@Eigenwise

Copy link
Copy Markdown
Owner

Summary

Changes

  • atomic-agents/atomic_agents/context/chat_history.py: Rewrote get_history() multimodal handling with a new _extract_multimodal_info() static method that recursively walks nested schemas at any depth
  • atomic-agents/tests/context/test_chat_history.py: Added 6 comprehensive tests (nested + top-level multimodal, deeply nested only, mixed, lists of nested schemas, all-multimodal, backwards compat)
  • atomic-examples/nested-multimodal/: New end-to-end example demonstrating nested multimodal schemas working with an actual LLM call

Test plan

  • All 274 existing tests pass
  • 6 new tests cover both issue scenarios and edge cases
  • End-to-end example verified with gpt-5-mini (serialization + LLM call)
  • Reviewer verifies no regressions in multimodal examples

🤖 Generated with Claude Code

Eigenwise and others added 4 commits February 11, 2026 14:38
ChatHistory.get_history() now recursively extracts multimodal objects
(Image, PDF, Audio) from arbitrarily nested Pydantic schemas, fixing
two related bugs:

- #208: TypeError when schemas have both multimodal fields and nested
  Pydantic models (json.dumps can't serialize Pydantic instances)
- #141: Multimodal content inside nested schemas was invisible to the
  shallow top-level field scan

The fix replaces the shallow field iteration + json.dumps with a single
recursive _extract_multimodal_info() method that builds a Pydantic
exclude spec, then uses model_dump_json(exclude=...) for correct
serialization of all remaining fields.

Adds 6 comprehensive tests and a nested-multimodal example.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Handle tuples identically to lists in _extract_multimodal_info
- Collapse dict exclude spec to True when all values are multimodal
- Add 10 direct unit tests for _extract_multimodal_info return values
- Add Dict[str, Image] integration test covering the dict code path
- Add exact content list length assertions to existing tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Eigenwise
Eigenwise merged commit f5f37f7 into main Feb 14, 2026
4 checks passed
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.

ChatHistory cannot handle multimodal data with nested Pydantic models AgentMemory: support nested multimodal data

1 participant