Skip to content

fix(openai-agents-sdk): increase agent max turns to 50 - #342

Merged
zimeg merged 1 commit into
mainfrom
fix-openai-max-turns
Dec 1, 2026
Merged

zimeg merged 1 commit into
mainfrom
fix-openai-max-turns

Conversation

@zimeg

@zimeg zimeg commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

The OpenAI Agents SDK for Python stops a run after 10 model calls by default, so longer requests that use several tools (including Slack MCP tools) fail with MaxTurnsExceeded: Max turns (10) exceeded.

This adds a MAX_TURNS = 50 constant in openai-agents-sdk/agent/support_agent.py and passes max_turns=MAX_TURNS to both runner calls (Runner.run_sync without the Slack MCP server and Runner.run with it). This matches the pattern in slack-samples/bolt-python-team-agent and slack-samples/bolt-python-coding-agent.

The other variants already have no such low limit (Claude Agent SDK sets no turn limit by default, Pydantic AI's default request limit is 50), so they are unchanged.

Testing

  • ruff check . and ruff format --check .: pass, 73 files already formatted
  • pytest: 18 passed, 0 failed
  • openai-agents 0.24.0: max_turns is a keyword on Runner.run and Runner.run_sync

🤖 Generated with Claude Code

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
zimeg requested a review from a team as a code owner December 1, 2026 00:56
@zimeg zimeg added the bug Something isn't working label Dec 1, 2026
@zimeg zimeg self-assigned this Dec 1, 2026

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Thanks @zimeg! A shared MAX_TURNS on both runner paths keeps Casey from tripping over longer Slack MCP requests, and it lines up nicely with the team and coding agents.

@zimeg

zimeg commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

🌟 Thanks for the kind review @mwbrooks!

@zimeg
zimeg merged commit 8c3057c into main Dec 1, 2026
8 checks passed
@zimeg
zimeg deleted the fix-openai-max-turns branch December 1, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants