Skip to content

feat(AIC-3106): add multimodal history support to graph().invoke() - #26

Merged
andrewklatzke merged 3 commits into
mainfrom
aklatzke/AIC-3106/add-graph-history
Sep 17, 2026
Merged

andrewklatzke merged 3 commits into
mainfrom
aklatzke/AIC-3106/add-graph-history

Conversation

@andrewklatzke

@andrewklatzke andrewklatzke commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds an optional history argument to graph().invoke() (and native graph runners), forwarded to the root node only on the first hop — subsequent nodes keep existing string-based data passing.
  • Shared compose_history helpers map LaunchDarkly-canonical multimodal content blocks to each provider’s native format (OpenAI Agents, Claude Agents/Messages, LangChain Agents/Messages).
  • Adds a graph-history integration example that asserts the model can identify a generated solid-color PNG from history.

Test plan

  • Unit tests for client graph plumbing + all handler/native-graph packages
  • Integration: uv run python main.py graph-history travel-agent-flow ""
  • Full integration suite (all integration-config.json scenarios, success + failure)
  • CI green on this PR

Note

Overview
Adds optional history to graph().invoke() and framework native graph runners, passing it only to the root node on the first hop; later nodes keep string-based handoffs.

Introduces shared compose_history and multimodal content helpers in the core client. Provider handlers (Claude/OpenAI/LangChain agents and messages) stop flattening history into the system prompt and instead build structured turns, mapping LD image/text blocks to each SDK’s native shape (streamed envelopes for Claude Agents, merged user turns for Claude Messages, input_image / image_url elsewhere).

Adds a graph-history example (generated red PNG + colour check) and broad unit/integration test coverage for plumbing and wire format.

Reviewed by Cursor Bugbot for commit 97dcdcd. Bugbot is set up for automated code reviews on this repo. Configure here.

Forward optional conversation history to the root node only, with
provider-native multimodal content blocks across agents and messages
handlers, plus a graph-history integration example.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit da9b323. Configure here.

Comment thread packages/claude-messages/src/launchdarkly_ai_claude_messages/handler.py Outdated
Comment thread packages/openai-agents/src/launchdarkly_ai_openai_agents/handler.py
- claude-messages: merge consecutive same-role turns so image-in-history
  plus a userInput question is sent as one user message (Anthropic requires
  alternating roles).
- openai-messages: only route through compose_history when history is
  present, so an instructions-only config with empty input still sends a
  user turn (empty history == no history).
- openai-agents: skip config.messages in history composition when
  config.instructions is set, matching the no-history priority (handler +
  native graph).

Co-authored-by: Cursor <cursoragent@cursor.com>
@andrewklatzke
andrewklatzke requested a review from apucacao August 11, 2026 20:51
Resolves conflicts in main.py, six provider handlers, and their test
modules, layering the PR's structured multimodal history onto main's
telemetry-aware handler architecture. History forwarding stays root-only,
as originally designed.

Also fixes two input-fidelity bugs found while validating the merge:

- claude-agents: envelope type and message.role must agree. Sending type
  'user' with message.role 'assistant' was rejected by the Claude Code CLI
  with "Expected message role 'user', got 'assistant'". Assistant turns now
  use an assistant envelope.
- openai-messages: restore role-aware content mapping. A role-blind mapper
  emitted input_text parts on assistant turns, which the Responses API
  accepts only on user turns.

Co-authored-by: Cursor <cursoragent@cursor.com>
@andrewklatzke
andrewklatzke merged commit c91132d into main Sep 17, 2026
7 checks passed
@andrewklatzke
andrewklatzke deleted the aklatzke/AIC-3106/add-graph-history branch September 17, 2026 01:05
@github-actions github-actions Bot mentioned this pull request Sep 17, 2026
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