Skip to content

feat: Introduce ManagedAgent and AgentRunner implementations#110

Merged
jsonbailey merged 9 commits intomainfrom
jb/aic-1664/managed-agent
Mar 31, 2026
Merged

feat: Introduce ManagedAgent and AgentRunner implementations#110
jsonbailey merged 9 commits intomainfrom
jb/aic-1664/managed-agent

Conversation

@jsonbailey
Copy link
Copy Markdown
Contributor

@jsonbailey jsonbailey commented Mar 25, 2026

feat: Add OpenAIAgentRunner with agentic tool-calling loop
feat: Add LangChainAgentRunner with agentic tool-calling loop
feat: Add OpenAIRunnerFactory.create_agent(config, tools) -> OpenAIAgentRunner
feat: Add LangChainRunnerFactory.create_agent(config, tools) -> LangChainAgentRunner
feat: Add ManagedAgent wrapper holding AgentRunner and LDAIConfigTracker
feat: Add LDAIClient.create_agent() returning ManagedAgent

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Medium Risk
Adds a new managed agent API plus new OpenAI/LangChain agent execution paths with tool handling and metrics extraction, which may affect runtime behavior and tracking across providers. Risk is mitigated by extensive new unit tests but touches core SDK surface area.

Overview
Adds first-class managed agent execution to the server AI SDK via LDAIClient.create_agent() returning a new ManagedAgent wrapper that runs an AgentRunner and auto-tracks invocation metrics.

Introduces new AgentRunner implementations for both providers: OpenAIAgentRunner (backed by openai-agents with optional native tools + model settings mapping) and LangChainAgentRunner (wraps langchain.agents.create_agent and aggregates token usage across graph messages). Provider factories (OpenAIRunnerFactory, LangChainRunnerFactory) now expose create_agent to construct these runners.

Updates token usage extraction to be more robust/consistent (LangChain prefers non-zero usage_metadata; OpenAI supports both chat completions and openai-agents results), and refactors native OpenAI tool mapping into openai_helper; adds/extends unit tests covering the new APIs, tool filtering/skipping, and usage parsing edge cases.

Written by Cursor Bugbot for commit 9295cc3. This will update automatically on new commits. Configure here.

@jsonbailey jsonbailey changed the title feat: Introduce ManagedAgent and AgentRunner implementations feat: Introduce ManagedAgent and AgentRunner implementations (PR-5) Mar 25, 2026
@jsonbailey jsonbailey force-pushed the jb/aic-1664/managed-agent branch from c3f2da2 to bc8b945 Compare March 26, 2026 13:27
@jsonbailey jsonbailey changed the base branch from jb/aic-1664/runner-abcs to jb/aic-1664/graph-tracking-improvements March 26, 2026 13:28
@jsonbailey jsonbailey marked this pull request as ready for review March 26, 2026 13:28
@jsonbailey jsonbailey requested a review from a team as a code owner March 26, 2026 13:28
Copy link
Copy Markdown
Member

@keelerm84 keelerm84 left a comment

Choose a reason for hiding this comment

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

Looks like bugbot has some good feedback on this one.

@jsonbailey jsonbailey force-pushed the jb/aic-1664/graph-tracking-improvements branch from 886e3b7 to a183f12 Compare March 26, 2026 17:49
Base automatically changed from jb/aic-1664/graph-tracking-improvements to main March 26, 2026 18:51
@jsonbailey jsonbailey force-pushed the jb/aic-1664/managed-agent branch from bc8b945 to c1b87a6 Compare March 26, 2026 19:20
@jsonbailey jsonbailey changed the title feat: Introduce ManagedAgent and AgentRunner implementations (PR-5) feat: Introduce ManagedAgent and AgentRunner implementations Mar 26, 2026
jsonbailey and others added 5 commits March 30, 2026 10:17
feat: Add OpenAIAgentRunner with agentic tool-calling loop
feat: Add LangChainAgentRunner with agentic tool-calling loop
feat: Add OpenAIRunnerFactory.create_agent(config, tools) -> OpenAIAgentRunner
feat: Add LangChainRunnerFactory.create_agent(config, tools) -> LangChainAgentRunner
feat: Add ManagedAgent wrapper holding AgentRunner and LDAIConfigTracker
feat: Add LDAIClient.create_agent() returning ManagedAgent
…ider helper tests

feat: add TestGetAIUsageFromResponse and TestGetToolCallsFromResponse test coverage for LangChainHelper
feat: add TestGetAIUsageFromResponse test coverage for OpenAIHelper
fix: update ManagedAgent.invoke to use track_metrics_of_async
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-1664/managed-agent branch from e4b3830 to afe344e Compare March 30, 2026 16:13
@jsonbailey jsonbailey requested a review from keelerm84 March 30, 2026 19:20
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@jsonbailey jsonbailey merged commit 53fd95e into main Mar 31, 2026
37 checks passed
@jsonbailey jsonbailey deleted the jb/aic-1664/managed-agent branch March 31, 2026 16:11
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
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.

2 participants