Skip to content

Decouple AI agent runtime construction#23912

Merged
luisorofino merged 3 commits into
loa/openmetrics-ai-genfrom
loa/solid-refactor
Jun 12, 2026
Merged

Decouple AI agent runtime construction#23912
luisorofino merged 3 commits into
loa/openmetrics-ai-genfrom
loa/solid-refactor

Conversation

@luisorofino

@luisorofino luisorofino commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Refactors the AI framework runtime construction path so callers pass a single AgentRuntime through the ReAct flow instead of manually carrying separate agent and tool registry objects.

This PR:

  • Replaces worker/subagent/goal-specific builders in ddev.ai.agent.build with one generic AgentRuntimeFactory.build_runtime(...) API.
  • Keeps AgentRuntime as the pair of agent + tool registry, and updates ReActProcess to accept that runtime directly.
  • Moves orchestration-specific policy out of the agent layer:
    • AgenticPhase renders the worker system prompt and provides the selected parent AgentConfig.
    • phases.goal derives the reviewer config, including read-only tools and the reviewer prompt.
    • SpawnSubagentTool derives child agent configs and allowed child tools from the parent config.
  • Simplifies ToolRegistry context by removing subagent-specific builder/allowed-tool plumbing and passing generic runtime infrastructure to tool factories.
  • Updates AI framework tests for runtime construction, ReAct process wiring, goal validation, subagent spawning, and registry construction.

Motivation

The previous design introduced AgentRuntime, but ReActProcess and several call sites still unpacked runtime objects into separate agent and tool-registry values. The agent build layer also knew too much about goal reviewers and subagents, which made phase policy leak into generic agent construction.

This refactor keeps agent.build focused on constructing runtimes from explicit inputs, while goal and subagent-specific behavior stays in the modules that own those workflows. The result is a smaller builder API, clearer ownership boundaries, and less duplicated runtime wiring.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@luisorofino luisorofino added the qa/skip-qa Automatically skip this PR for the next QA label Jun 2, 2026
@dd-octo-sts dd-octo-sts Bot added the ddev label Jun 2, 2026
@luisorofino luisorofino changed the title Refactor Agent build Decouple AI agent runtime construction Jun 2, 2026
@datadog-official

datadog-official Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Pipelines  Tests  Code Coverage

Fix all issues with BitsAI

⚠️ Warnings

🚦 5 Pipeline jobs failed

PR All | test / j06ca546 / SNMP   View in Datadog   GitHub Actions

PR All | test / j91231ff (py3.13-6.0-standalone) / MongoDB-py3.13-6.0-standalone   View in Datadog   GitHub Actions

PR All | test / j9eb6aa6 / DuckDB   View in Datadog   GitHub Actions

View all 5 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 98.86%
Overall Coverage: 87.91%

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 945cd70 | Docs | Datadog PR Page | Give us feedback!

@luisorofino luisorofino marked this pull request as ready for review June 2, 2026 15:17
@luisorofino luisorofino requested a review from a team as a code owner June 2, 2026 15:17
Comment thread ddev/src/ddev/ai/phases/goal.py
Comment thread ddev/tests/ai/agent/test_build.py
Comment thread ddev/src/ddev/ai/phases/orchestrator.py
Comment thread ddev/src/ddev/ai/tools/registry.py
Comment thread ddev/src/ddev/ai/tools/agents/spawn_subagent.py
Comment thread ddev/src/ddev/ai/agent/build.py
Comment thread ddev/src/ddev/ai/agent/build.py
Base automatically changed from loa/build-phase to loa/openmetrics-ai-gen June 9, 2026 07:22
@luisorofino luisorofino force-pushed the loa/solid-refactor branch 2 times, most recently from 2fa1a3b to b83e49a Compare June 10, 2026 09:29
@dd-octo-sts

dd-octo-sts Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@luisorofino luisorofino merged commit 2af18eb into loa/openmetrics-ai-gen Jun 12, 2026
333 of 338 checks passed
@luisorofino luisorofino deleted the loa/solid-refactor branch June 12, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddev qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants