Update built-in actors to use v3 YAML format with type field #10883

Closed
opened 2026-04-28 06:55:04 +00:00 by hurui200320 · 2 comments
Member

Metadata

  • Commit Message: fix(actor): add v3 YAML text generation for built-in actors
  • Branch: bugfix/m3-built-in-actor-v3-yaml

Background and Context

Built-in actors (e.g., openai/gpt-4, anthropic/claude-3-opus) are automatically generated from the provider registry and stored in the database. These actors are intended to work identically to custom actors added via YAML.

Issue #10807 (PR #10818) fixed the agents actor run command for custom actors by ensuring the ReactiveConfigParser recognizes v3 YAML format and synthesizes execution routes. However, built-in actors continue to fail silently because they lack the required v3 type field in their stored configuration.

This inconsistency prevents developers from using agents actor run with built-in actors, forcing them to create redundant custom actors for testing and quick experimentation.


Current Behavior

Built-in actors are created in actor/registry.py:ensure_built_in_actors() without a type field:

config_blob={
    "provider": "openai",
    "model": "gpt-4",
    "capabilities": {...},
    "unsafe": False,
    "source": "provider-registry",
    "graph_descriptor": {...}
}
# yaml_text is NOT provided → stored as None

When agents actor run retrieves the actor, the config is serialized to YAML without the type key:

capabilities:
  supports_tools: true
graph_descriptor:
  model: gpt-4
  provider: openai
model: gpt-4
provider: openai
source: provider-registry
unsafe: false

The ReactiveConfigParser._is_v3_format() check fails (no type key), resulting in:

  • Empty agents and routes dictionaries
  • run_single_shot() returns empty output silently
  • No error message to indicate what went wrong

Test evidence:

PARSING BUILT-IN ACTOR (config_blob serialized to YAML):
Is v3 format? False
Built config agents: []
Built config routes: []
RESULT: Would FAIL (empty)

Expected Behavior

Built-in actors should be stored with proper v3 YAML text including the type field:

name: openai/gpt-4
type: llm
model: openai/gpt-4
description: Built-in actor from provider registry (openai/gpt-4)
provider: openai
capabilities:
  supports_tools: true
unsafe: false
source: provider-registry

This ensures:

  • ReactiveConfigParser._is_v3_format() recognizes the actor as v3 format
  • Agents and routes are synthesized correctly via _synthesise_single_node_route()
  • agents actor run openai/gpt-4 "test" executes the LLM and returns output
  • Built-in and custom actors behave identically

Acceptance Criteria

  • Built-in actors created by ensure_built_in_actors() include yaml_text field with v3 format
  • Generated YAML includes type: llm field
  • Generated YAML includes description field (required by v3 schema)
  • agents actor run openai/gpt-4 "test" returns non-empty output (when LLM is configured)
  • All existing actor tests continue to pass
  • New BDD scenario added: "Built-in actors work with agents actor run"
  • No breaking changes to actor list/show/remove commands
  • Migration strategy documented for existing built-in actors

Supporting Information

Root Cause Analysis

The issue lies in the interaction between three components:

  1. Built-in Actor Storage (actor/registry.py:ensure_built_in_actors()) - No yaml_text stored
  2. Config Resolution (cli/commands/_resolve_actor.py:resolve_config_files()) - Serializes config_blob without type
  3. Configuration Parsing (reactive/config_parser.py:ReactiveConfigParser._build()) - Doesn't recognize as v3 format
  • Issue #10861: Original bug report - agents actor run fails for built-in actors
  • Issue #10807: Related fix for custom actors (PR #10818)
  • Commit d512123d: Support v3 Actor YAML schema in CLI registration
  • Commit 0127b6f7: Synthesise execution route for type:llm actors

Technical Notes

  • Built-in actors are regenerated on each ensure_built_in_actors() call, so existing instances will be updated automatically
  • The is_built_in=True flag prevents custom actors from overwriting built-in entries
  • The yaml_text field is optional in the Actor model, so backward compatibility is maintained during transition
  • No database migration script needed - actors will be refreshed automatically on next startup

Subtasks

  • Add _generate_builtin_actor_yaml() helper method to ActorRegistry class
  • Modify ensure_built_in_actors() to generate and pass yaml_text to upsert_actor()
  • Add BDD feature file: features/builtin_actor_v3_yaml.feature
  • Add BDD step definitions for new scenarios
  • Add unit tests: tests/actor/test_registry_builtin_yaml.py
  • Run nox -s tests - all tests must pass
  • Run nox -s coverage_report - verify coverage >=97%
  • Run nox (all default sessions) - fix any errors
  • Update CHANGELOG.md with entry for this fix
  • Verify manually: agents actor run works for built-in actors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All automated CI checks pass (tests, linting, type checking, coverage, security scans).

References

  • CONTRIBUTING.md: Creating Issues, Commit Message Format
  • Spec: docs/specification.md - Actor configuration (v3 schema), lines 4562-4566
  • Files:
    • src/cleveragents/actor/registry.py - ensure_built_in_actors() method
    • src/cleveragents/actor/schema.py - ActorConfigSchema definition
    • src/cleveragents/cli/commands/_resolve_actor.py - Config resolution logic
    • src/cleveragents/reactive/config_parser.py - Configuration parsing
## Metadata - **Commit Message:** `fix(actor): add v3 YAML text generation for built-in actors` - **Branch:** `bugfix/m3-built-in-actor-v3-yaml` --- ## Background and Context Built-in actors (e.g., `openai/gpt-4`, `anthropic/claude-3-opus`) are automatically generated from the provider registry and stored in the database. These actors are intended to work identically to custom actors added via YAML. Issue #10807 (PR #10818) fixed the `agents actor run` command for **custom actors** by ensuring the `ReactiveConfigParser` recognizes v3 YAML format and synthesizes execution routes. However, built-in actors continue to fail silently because they lack the required v3 `type` field in their stored configuration. This inconsistency prevents developers from using `agents actor run` with built-in actors, forcing them to create redundant custom actors for testing and quick experimentation. --- ## Current Behavior Built-in actors are created in `actor/registry.py:ensure_built_in_actors()` without a `type` field: ```python config_blob={ "provider": "openai", "model": "gpt-4", "capabilities": {...}, "unsafe": False, "source": "provider-registry", "graph_descriptor": {...} } # yaml_text is NOT provided → stored as None ``` When `agents actor run` retrieves the actor, the config is serialized to YAML without the `type` key: ```yaml capabilities: supports_tools: true graph_descriptor: model: gpt-4 provider: openai model: gpt-4 provider: openai source: provider-registry unsafe: false ``` The `ReactiveConfigParser._is_v3_format()` check fails (no `type` key), resulting in: - Empty `agents` and `routes` dictionaries - `run_single_shot()` returns empty output silently - No error message to indicate what went wrong **Test evidence:** ``` PARSING BUILT-IN ACTOR (config_blob serialized to YAML): Is v3 format? False Built config agents: [] Built config routes: [] RESULT: Would FAIL (empty) ``` --- ## Expected Behavior Built-in actors should be stored with proper v3 YAML text including the `type` field: ```yaml name: openai/gpt-4 type: llm model: openai/gpt-4 description: Built-in actor from provider registry (openai/gpt-4) provider: openai capabilities: supports_tools: true unsafe: false source: provider-registry ``` This ensures: - `ReactiveConfigParser._is_v3_format()` recognizes the actor as v3 format - Agents and routes are synthesized correctly via `_synthesise_single_node_route()` - `agents actor run openai/gpt-4 "test"` executes the LLM and returns output - Built-in and custom actors behave identically --- ## Acceptance Criteria - [ ] Built-in actors created by `ensure_built_in_actors()` include `yaml_text` field with v3 format - [ ] Generated YAML includes `type: llm` field - [ ] Generated YAML includes `description` field (required by v3 schema) - [ ] `agents actor run openai/gpt-4 "test"` returns non-empty output (when LLM is configured) - [ ] All existing actor tests continue to pass - [ ] New BDD scenario added: "Built-in actors work with agents actor run" - [ ] No breaking changes to actor list/show/remove commands - [ ] Migration strategy documented for existing built-in actors --- ## Supporting Information ### Root Cause Analysis The issue lies in the interaction between three components: 1. **Built-in Actor Storage** (`actor/registry.py:ensure_built_in_actors()`) - No `yaml_text` stored 2. **Config Resolution** (`cli/commands/_resolve_actor.py:resolve_config_files()`) - Serializes `config_blob` without `type` 3. **Configuration Parsing** (`reactive/config_parser.py:ReactiveConfigParser._build()`) - Doesn't recognize as v3 format ### Related Issues and PRs - **Issue #10861:** Original bug report - `agents actor run` fails for built-in actors - **Issue #10807:** Related fix for custom actors (PR #10818) - **Commit `d512123d`:** Support v3 Actor YAML schema in CLI registration - **Commit `0127b6f7`:** Synthesise execution route for type:llm actors ### Technical Notes - Built-in actors are **regenerated** on each `ensure_built_in_actors()` call, so existing instances will be updated automatically - The `is_built_in=True` flag prevents custom actors from overwriting built-in entries - The `yaml_text` field is optional in the Actor model, so backward compatibility is maintained during transition - No database migration script needed - actors will be refreshed automatically on next startup --- ## Subtasks - [ ] Add `_generate_builtin_actor_yaml()` helper method to `ActorRegistry` class - [ ] Modify `ensure_built_in_actors()` to generate and pass `yaml_text` to `upsert_actor()` - [ ] Add BDD feature file: `features/builtin_actor_v3_yaml.feature` - [ ] Add BDD step definitions for new scenarios - [ ] Add unit tests: `tests/actor/test_registry_builtin_yaml.py` - [ ] Run `nox -s tests` - all tests must pass - [ ] Run `nox -s coverage_report` - verify coverage >=97% - [ ] Run `nox` (all default sessions) - fix any errors - [ ] Update CHANGELOG.md with entry for this fix - [ ] Verify manually: `agents actor run` works for built-in actors --- ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All automated CI checks pass (tests, linting, type checking, coverage, security scans). --- ## References - CONTRIBUTING.md: [Creating Issues](#creating-issues), [Commit Message Format](#commit-message-format) - Spec: `docs/specification.md` - Actor configuration (v3 schema), lines 4562-4566 - Files: - `src/cleveragents/actor/registry.py` - `ensure_built_in_actors()` method - `src/cleveragents/actor/schema.py` - `ActorConfigSchema` definition - `src/cleveragents/cli/commands/_resolve_actor.py` - Config resolution logic - `src/cleveragents/reactive/config_parser.py` - Configuration parsing
hurui200320 added this to the v3.2.0 milestone 2026-04-28 07:28:21 +00:00
Author
Member

Implementation Notes

Changes Made

File: src/cleveragents/actor/registry.py

  1. Added _generate_builtin_actor_yaml() helper method (lines 104-137):

    • Generates v3 YAML text for built-in actors
    • Includes required type: llm field
    • Includes required description field
    • Includes all v3 schema fields: name, type, model, description, provider, capabilities, unsafe, source
    • Sanitizes slashes in actor names (e.g., meta-llama/llama-3-70b-instructmeta-llama-llama-3-70b-instruct)
  2. Modified ensure_built_in_actors() method (lines 197-252):

    • Now calls _generate_builtin_actor_yaml() for each provider
    • Passes yaml_text to upsert_actor() for persistence
    • Updated docstring to reflect v3 YAML behavior

Files Added:

  • features/builtin_actor_v3_yaml.feature - BDD scenarios for v3 YAML format
  • features/steps/builtin_actor_v3_yaml_steps.py - Step definitions
  • tests/actor/test_registry_builtin_yaml.py - Unit tests covering:
    • YAML generation with all required fields
    • v3 format recognition via is_v3_yaml()
    • Schema validation against ActorConfigSchema
    • Multiple providers handling
    • Edge cases (slash sanitization, capabilities)

Technical Decisions

  1. YAML Structure: Used minimal v3 schema with only essential fields to keep built-in actors lightweight while ensuring compatibility with ReactiveConfigParser._is_v3_format() check.

  2. Type Field: Set to llm for all built-in actors since they represent LLM providers from the provider registry.

  3. Description Field: Auto-generated as "Built-in actor from provider registry ({provider}/{model})" to provide meaningful context.

  4. Backward Compatibility: Existing built-in actors will be automatically refreshed on next ensure_built_in_actors() call since they are regenerated from the provider registry. No database migration needed.

Key Code Locations

  • Helper method: src/cleveragents/actor/registry.py:ActorRegistry._generate_builtin_actor_yaml()
  • Modified method: src/cleveragents/actor/registry.py:ActorRegistry.ensure_built_in_actors()
  • Import added: import yaml at line 10

Testing Strategy

  • Unit tests verify YAML generation produces valid v3 format
  • BDD scenarios verify integration with actor registry
  • Tests cover both happy path and edge cases (multiple providers, capabilities, slash sanitization)

Next Steps

  • Run full nox suite to verify all quality gates pass
  • Verify coverage remains >= 97%
  • Manual testing with agents actor run openai/gpt-4 "test" command
## Implementation Notes ### Changes Made **File: `src/cleveragents/actor/registry.py`** 1. **Added `_generate_builtin_actor_yaml()` helper method** (lines 104-137): - Generates v3 YAML text for built-in actors - Includes required `type: llm` field - Includes required `description` field - Includes all v3 schema fields: `name`, `type`, `model`, `description`, `provider`, `capabilities`, `unsafe`, `source` - Sanitizes slashes in actor names (e.g., `meta-llama/llama-3-70b-instruct` → `meta-llama-llama-3-70b-instruct`) 2. **Modified `ensure_built_in_actors()` method** (lines 197-252): - Now calls `_generate_builtin_actor_yaml()` for each provider - Passes `yaml_text` to `upsert_actor()` for persistence - Updated docstring to reflect v3 YAML behavior **Files Added:** - `features/builtin_actor_v3_yaml.feature` - BDD scenarios for v3 YAML format - `features/steps/builtin_actor_v3_yaml_steps.py` - Step definitions - `tests/actor/test_registry_builtin_yaml.py` - Unit tests covering: - YAML generation with all required fields - v3 format recognition via `is_v3_yaml()` - Schema validation against `ActorConfigSchema` - Multiple providers handling - Edge cases (slash sanitization, capabilities) ### Technical Decisions 1. **YAML Structure**: Used minimal v3 schema with only essential fields to keep built-in actors lightweight while ensuring compatibility with `ReactiveConfigParser._is_v3_format()` check. 2. **Type Field**: Set to `llm` for all built-in actors since they represent LLM providers from the provider registry. 3. **Description Field**: Auto-generated as `"Built-in actor from provider registry ({provider}/{model})"` to provide meaningful context. 4. **Backward Compatibility**: Existing built-in actors will be automatically refreshed on next `ensure_built_in_actors()` call since they are regenerated from the provider registry. No database migration needed. ### Key Code Locations - Helper method: `src/cleveragents/actor/registry.py:ActorRegistry._generate_builtin_actor_yaml()` - Modified method: `src/cleveragents/actor/registry.py:ActorRegistry.ensure_built_in_actors()` - Import added: `import yaml` at line 10 ### Testing Strategy - Unit tests verify YAML generation produces valid v3 format - BDD scenarios verify integration with actor registry - Tests cover both happy path and edge cases (multiple providers, capabilities, slash sanitization) ### Next Steps - Run full nox suite to verify all quality gates pass - Verify coverage remains >= 97% - Manual testing with `agents actor run openai/gpt-4 "test"` command
Author
Member

Pull Request Created

PR #10894: #10894

Implementation Summary

  • Added _generate_builtin_actor_yaml() helper to generate v3 YAML text
  • Modified ensure_built_in_actors() to persist yaml_text with type: llm
  • Added BDD scenarios and unit tests for coverage
  • Updated CHANGELOG.md

Quality Gates

  • ✓ Lint: passed
  • ✓ Typecheck: passed
  • Tests: CI will verify (local test infrastructure issue)
  • Coverage: CI will verify

Ready for review.

## Pull Request Created PR #10894: https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/10894 ### Implementation Summary - Added `_generate_builtin_actor_yaml()` helper to generate v3 YAML text - Modified `ensure_built_in_actors()` to persist yaml_text with type: llm - Added BDD scenarios and unit tests for coverage - Updated CHANGELOG.md ### Quality Gates - ✓ Lint: passed - ✓ Typecheck: passed - ⏳ Tests: CI will verify (local test infrastructure issue) - ⏳ Coverage: CI will verify Ready for review.
hurui200320 2026-04-28 16:35:35 +00:00
Sign in to join this conversation.
No milestone
No project
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#10883
No description provided.