Skip to content

Add regression tests for tool_calls assignment in assistant message#1

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1776315417-tool-calls-regression-test
Open

Add regression tests for tool_calls assignment in assistant message#1
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1776315417-tool-calls-regression-test

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Apr 16, 2026

Copy link
Copy Markdown

Summary

Adds a test suite (01-tools/tests/test_agent.py) that guards against the bug fixed in commit 99c1873, where tool_calls was unconditionally included in the assistant message dict — even as an empty list — which could cause issues with LLM providers that reject empty tool_calls.

The four tests cover:

  • tool_calls is present and correctly structured when the LLM returns tool calls
  • tool_calls key is absent when the LLM returns no tool calls (the core regression check)
  • Multiple tool calls are all correctly assigned
  • content field is preserved correctly in both cases within a single multi-turn conversation

Tests mock LLMProvider.chat() and ToolRegistry.execute_tool so no real API keys or tool execution is needed.

Review & Testing Checklist for Human

  • Coverage scope: Tests are only added for 01-tools. The same fix was applied to all 17 step directories, and their agent.py files diverge (e.g., event-driven steps 07+ have different structure). Decide whether regression tests should also cover at least one of the later steps (e.g., 07-event-driven or 15-agent-dispatch).
  • Run the tests locally: cd 01-tools && pip install -e . && pip install pytest pytest-asyncio && python -m pytest tests/test_agent.py -v — verify all 4 tests pass.
  • No CI configured: This repo has no CI pipeline, so tests are not automatically run on push. Consider whether a GitHub Actions workflow should be added.

Notes

  • The FakeAgentDef dataclass avoids pulling in the full config/loader stack by providing just the agent_md field needed by SessionState.build_messages().
  • No existing test infrastructure was present in the repo; this is the first test file.

Link to Devin session: https://app.devin.ai/sessions/ff9168be75af4dec91fa687c596c2359
Requested by: @tashik


Open with Devin

Tests verify that:
- tool_calls is present and correctly assigned when LLM returns tool calls
- tool_calls key is absent when LLM returns no tool calls
- Multiple tool calls are all correctly assigned
- Content field is preserved regardless of tool_calls presence

Guards against regression of the bug fixed in 99c1873 where tool_calls
was always included in the assistant message dict even when empty.

Co-Authored-By: Nataly Andries <patrinat@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: Nataly Andries <patrinat@gmail.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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