Repository navigation
[api][docs] Support YAML subagents and clarify the YAML reference - #1269
Merged
Merged
Conversation
Use message templates when text is empty, matching PromptSpec validation. Cover omitted, null and empty text with message role, order and formatting assertions. Generated-by: Codex CLI 0.153.4 (GPT-6) Co-authored-by: Codex <codex@openai.com>
Resolve agent-local subagent references against all Agents in the current file and Agents already registered in the same execution environment. Load files in order and reject duplicate Agent names before binding. Reuse the existing descriptor builder, plan cycle validation, serialization and runtime invocation path. Keep top-level subagents external and preserve external setup configuration arguments. Cover forward and cross-file references, reused and nested children, invalid declarations, cycles, duplicate names, failure state, shared child actions and schema parity. Verify parent and child application and a serialized-plan invocation on the Java operator. Update both published schema copies and the bundled contract hash. Generated-by: Codex CLI 0.153.4 (GPT-6) Co-authored-by: Codex <codex@openai.com>
Explain the boundary between YAML configuration and implementation code. Clarify prompt validation, required fields, type applicability and provider aliases. Keep tool injection and skill source behavior in their dedicated guides, and remove maintainer-only mapping and consistency details. Document internal child references and external subagent setups, including examples, input schema configuration, cross-file loading order, name uniqueness and cycle validation. Link the YAML and Subagents guides in both directions. Validated with Hugo and internal links/anchors in both the current tree and a temporary documentation overlay of PR apache#1261. Subagent examples pass the Pydantic models and generated JSON Schema, with the incremental fragment combined with the earlier single-agent example. Generated-by: Codex CLI 0.153.4 (GPT-6) Co-authored-by: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1231
Purpose of change
YAML can now register internal sub-agents by referencing another Agent in the same file or one already loaded into the same execution environment. The Prompt loader also preserves message templates when
textis empty, matching the existing validation rule.The YAML reference now separates configuration from implementation code, clarifies required fields and aliases, links to Tool Use and Skills for behavior, and documents sub-agents. The changes are split into three commits: Prompt fix, sub-agent support, and documentation.
The implementation description covers the two code changes.
Runtime flow
Each loader creates all Agents in a file, then binds agent-local
subagentsentries against those Agents and the environment's previously registered Agents. Internal references use the existing descriptor builder; plan compilation serializes the child and checks cycles. Runtime invocation follows the existing sub-agent path. Files are loaded in order.Prompt construction selects non-empty
text; otherwise it constructs the validated message list.Key decisions
clazzto select the existing external descriptor form, preserving arbitrary provider configuration, including anagentargument.Behavioral Semantics
Interaction decisions
clazz, withagentnameis the parent's resource nameclazzagentreferencemessageswith omitted/null/emptytextBehavioral contracts
descriptionmay be omitted/null;input_schema, when supplied, is a YAML mapping. Model delegation retains the existing input-schema requirement.Failure behavior
Invalid internal declarations, unsupported shared internal references, duplicate names, and unknown children raise during loading. Unknown-child and duplicate-Agent failures leave the failing file's Agents/resources unregistered and preserve earlier registrations. Self-reference and indirect cycles raise during plan construction. No retry or deferred resolution is added; provider/service failures are unchanged.
Tests
Verification: 152 Java tests and 171 Python tests passed. Hugo built successfully; 761 internal links/anchors and the bundled schema/hash were checked.
YamlSubagentTest.resolvesChildInEitherOrder; Pythontest_internal_reference_preserves_child_and_metadataYamlLoaderLoadYamlTest.resolvesPreviouslyLoadedChild; Pythontest_child_in_previously_loaded_file_is_resolvedchildMustBeLoadedFirstAndFailurePreservesState; Python matching failure/state testscurrentFileCannotReplaceRegisteredChild; Pythontest_current_file_cannot_replace_registered_childYamlSubagentPlanTest; Pythontest_yaml_subagents.pyYamlSubagentTest; Pythontest_subagents.pyexternalDeclarationsPreserveProviderArguments; Pythontest_external_subagents_preserve_provider_argumentsrecursiveReferencesFailPlanConstruction; Pythontest_yaml_cycles_use_existing_plan_validationInternalSubagentCallTest.yamlParentInvokesChildAfterPlanSerialization(JDK 21)YamlLoaderBuildersTest.buildPromptMessagesWithUnsetText; Pythontest_build_agents_preserves_prompt_messages_with_unset_textCoverage concentrates on reference binding, failure state, plan serialization, and actual Java operator invocation. Not verified: full cluster/cross-language E2E or live model/external-provider calls; the full repository test suite was not run.
API
Adds the agent-local internal YAML form (
name,agent, optionaldescriptionand mappinginput_schema) in both languages and the published schema. External declarations and runtime APIs are unchanged. Existing valid Prompt YAML with emptytextplus messages now produces the intended message prompt. Files with duplicate Agent names remain invalid.Documentation
doc-neededdoc-not-neededdoc-includedWas this patch authored or co-authored using generative AI tooling?
Generated-by: Codex CLI 0.153.4 (GPT-6)