Skip to content

fix(memory): preserve text parts after multimodal user prompts - #300

Open
Cookie0103 wants to merge 1 commit into
ANative-Lab:mainfrom
Cookie0103:fix/multimodal-user-context
Open

Cookie0103 wants to merge 1 commit into
ANative-Lab:mainfrom
Cookie0103:fix/multimodal-user-context

Conversation

@Cookie0103

Copy link
Copy Markdown

When ContextManager.add_user_prompt() receives multimodal content followed by a string, it applies list += string. The follow-up text becomes one array entry per character, so the conversation contains invalid content parts instead of a text block. For example, adding an image and then "Describe this image." corrupts the user message sent to the model.

Append a structured {"type": "text", "text": ...} part when the existing user content is a list. Preserve the current text/text, text/list and list/list behavior. The parameterized regression covers all four combinations in native and prompt-based tool-calling modes and checks that caller-owned input lists are not changed.

Validation (Python 3.12, repository requirements installed):

  • Before the fix: 2 failures and 6 passes in the new cases; both failures were list-then-text.
  • New cases plus CustomizeAction context/agent-loop tests: 34 passed.
  • Full pytest tests/ -q --maxfail=3: 277 passed, 8 warnings. LITELLM_LOCAL_MODEL_COST_MAP=True and an empty OPENAI_API_KEY were used; no live model request was used. The first sandboxed attempt could not download the public GSM8K fixture or create multiprocessing sockets; the authorized rerun passed.
  • The new test file passes Ruff and git diff --check passes. Repository-wide Ruff currently reports existing violations. The changed production module has the same eight annotation-modernization diagnostics on the unmodified base and this branch; this PR does not reformat unrelated code.

AI assistance: Codex investigated, implemented and ran these checks on behalf of the account owner. The account owner has not independently reviewed or tested the contribution.

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.

1 participant