Skip to content

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

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/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, and the Vercel AI SDK for Python sets no step limit), so they are unchanged.

Testing

  • ruff check . and ruff format --check .: pass, 64 files already formatted
  • pytest: 14 passed, 0 failed
  • openai-agents 0.26.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! Lifting the cap to 50 means a few MCP searches in one request no longer trip MaxTurnsExceeded, and matching the team and coding agents keeps the samples consistent.

@zimeg

zimeg commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

🌟 Thanks for the kind review @mwbrooks!

@zimeg
zimeg merged commit d00186c into main Dec 1, 2026
10 checks passed
@zimeg
zimeg deleted the fix-openai-max-turns branch December 1, 2026 01:22
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