Skip to content

fix(smolagents): accept tuple inputs for messages, content parts, and task images - #912

Open
SAMurai-16 wants to merge 6 commits into
open-telemetry:mainfrom
SAMurai-16:fix/smolagents-tuple-inputs
Open

SAMurai-16 wants to merge 6 commits into
open-telemetry:mainfrom
SAMurai-16:fix/smolagents-tuple-inputs

Conversation

@SAMurai-16

Copy link
Copy Markdown
Contributor

Description

In opentelemetry.instrumentation.genai.smolagents:

  • to_input_messages had an early return if not isinstance(messages, list): return [], causing messages passed as tuples to be silently dropped.
  • _parts_from_content only checked if isinstance(content, list):, dropping content parts passed as a tuple.
  • task_to_input_messages checked if isinstance(images, list):, dropping images passed as a tuple.
  • _stop_sequences in patch.py checked if isinstance(stop, list):, dropping stop sequences passed as a tuple.
    This PR relaxes these collection checks to (list, tuple) and updates the typing to Sequence[...], consistent with PR fix(bedrock): accept tuple inputs #870 (bedrock) and PR fix(google-genai): handle tuple contents during capture #861 (google-genai).

Fixes #905

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

  • All 130 unit/integration tests in opentelemetry-instrumentation-genai-smolagents pass.
  • Formatted and linted cleanly via pre-commit / tox -e ruff.

Checklist

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

… task images

- Support messages passed as tuples in to_input_messages
- Support content parts passed as tuples in _parts_from_content
- Support images passed as tuples in task_to_input_messages
- Support stop sequences passed as tuples in _stop_sequences
- Add unit tests in test_models and test_agents covering tuple inputs
@SAMurai-16
SAMurai-16 requested a review from a team as a code owner October 17, 2026 13:34
Copilot AI balanced review requested due to automatic review settings October 17, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-01 09:15 UTC

Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):

  • Top-level threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@AgentGymLeader AgentGymLeader left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran the smolagents latest and oldest envs on 4db5747: all pass. _stop_sequences has no tuple test: mlx_model(stop=("STOP",)) should record ("STOP",) as the stop sequences, and that assertion fails on main.

@eternalcuriouslearner eternalcuriouslearner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we also add a streamed-generation test with tuple inputs? Both paths share request capture, so this would be additional regression coverage rather than a blocker.

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Hi @SAMurai-16 — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.

  • Replying is enough to hand it off — answer, explain why no change is needed, or ask a follow-up. The dashboard routes it onward once nothing on the list is waiting on you.
  • To hand it back for any other reason, including the dashboard getting this wrong, comment /dashboard route:reviewers.

@SAMurai-16

Copy link
Copy Markdown
Contributor Author

Added test_generate_stream_with_tuple_messages in tests/test_models.py to cover streamed generation with tuple messages and content parts. Ran the test suite across both oldest and latest environments.

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

Development

Successfully merging this pull request may close these issues.

fix(smolagents): accept tuple inputs for messages, content, and task images

4 participants