Skip to content

refactor(server): migrate to Agents SDK backend#12

Merged
matheusgalvao1 merged 2 commits intomainfrom
feat/openai-agents-sdk
Feb 26, 2026
Merged

refactor(server): migrate to Agents SDK backend#12
matheusgalvao1 merged 2 commits intomainfrom
feat/openai-agents-sdk

Conversation

@matheusgalvao1
Copy link
Collaborator

Purpose

Migrate server-side agent execution to OpenAI Agents SDK as the single backend path and remove legacy Responses adapter code.

What changed

  • remove legacy OpenAI Responses adapter service and server backend-switching logic
  • keep one WorkflowLLM implementation backed by OpenAI Agents SDK
  • set explicit maxTurns to 20 for bounded agent-loop iterations
  • update server dependency graph and lockfile for @openai/agents
  • update AGENTS.md, CLAUDE.md, and README guidance to match the new backend and worktree submodule initialization requirements

Risk / Impact

  • agent node execution behavior now depends exclusively on @openai/agents
  • long-running or tool-heavy prompts now fail earlier with MaxTurnsExceededError at 20 turns
  • no API contract changes to workflow routes or node schema

Linked issue

  • none

Validation

  • npm --workspace apps/server run typecheck
  • npx eslint apps/server/src/index.ts apps/server/src/services/openai-agents-llm.ts
  • npm run typecheck

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

The pull request migrates the LLM backend from the OpenAI Responses API to the OpenAI Agents SDK. Changes include replacing OpenAILLMService with a new OpenAIAgentsLLMService that dynamically loads the agents SDK and executes agents with a capped turn limit. The package.json dependency is updated from "openai" to "@openai/agents". The main application entry point is modified to instantiate the new service. Documentation files are updated to reflect the architectural shift and include guidance on initializing git submodules.

Suggested reviewers

  • maria-codesignal
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: migrating from the legacy OpenAI Responses adapter to the OpenAI Agents SDK backend, which is the primary objective of the entire PR.
Description check ✅ Passed The description clearly relates to the changeset, providing purpose, scope, risk assessment, and validation steps that align with the file changes and PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/server/src/services/openai-agents-llm.ts (1)

74-74: Add a timeout via AbortSignal to bound wall-clock runtime for sdk.run().

maxTurns alone doesn't prevent slow network or tool steps from extending request duration indefinitely. Use AbortSignal.timeout() to enforce a timeout:

Example implementation
const result = await sdk.run(agent, invocation.userContent, {
  maxTurns: MAX_AGENT_TURNS,
  signal: AbortSignal.timeout(10_000), // 10s timeout
});

Adjust the timeout value based on expected runtime for your agents.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/server/src/services/openai-agents-llm.ts` at line 74, The call to
sdk.run(agent, invocation.userContent, { maxTurns: MAX_AGENT_TURNS }) needs a
wall-clock timeout; update the options passed to sdk.run (in the same scope
where agent, invocation.userContent and MAX_AGENT_TURNS are used) to include a
signal created via AbortSignal.timeout(<ms>) (e.g., 10_000 ms) so the request is
aborted after the desired duration; ensure any surrounding try/catch around
sdk.run handles the abort error appropriately.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/server/src/services/openai-agents-llm.ts`:
- Line 74: The call to sdk.run(agent, invocation.userContent, { maxTurns:
MAX_AGENT_TURNS }) needs a wall-clock timeout; update the options passed to
sdk.run (in the same scope where agent, invocation.userContent and
MAX_AGENT_TURNS are used) to include a signal created via
AbortSignal.timeout(<ms>) (e.g., 10_000 ms) so the request is aborted after the
desired duration; ensure any surrounding try/catch around sdk.run handles the
abort error appropriately.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51b1681 and 0b188dd.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • AGENTS.md
  • CLAUDE.md
  • README.md
  • apps/server/package.json
  • apps/server/src/index.ts
  • apps/server/src/services/openai-agents-llm.ts
  • apps/server/src/services/openai-llm.ts
💤 Files with no reviewable changes (1)
  • apps/server/src/services/openai-llm.ts

@matheusgalvao1 matheusgalvao1 merged commit 952c1b3 into main Feb 26, 2026
2 checks passed
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