refactor(s12_agent): SubagentTypeDescriptor + SubAgentBuildContext + parameterized PipelineFactory#199
Merged
Conversation
…parameterized PipelineFactory Phase D1 of the LLM backend upgrade. Unblocks multi-provider sub-agents by handing a build context to every factory — the descriptor's provider choice + the parent's CredentialBundle flow down so a sub-pipeline's Stage 6 can authenticate against any of the 6 registered providers. SubagentTypeDescriptor (s12_agent/subagent_type.py) - New fields: provider (sub-pipeline Stage 6), provider_credentials_extras (merged into ProviderCredentials.extras), parallel (orchestrator fan-out hint, fully landing in D2), max_concurrent (group-cap for parallel siblings). - ``model_override`` stays a string for back-compat; the plan's Optional[ModelConfig] upgrade is deferred to a follow-up. - ``extras`` now typed Mapping[str, Any]. SubAgentBuildContext (NEW, frozen) - parent_session_id / sub_session_id / credentials / descriptor / workspace_snapshot / parent_state_shared. Single channel the factory receives from the orchestrator. PipelineFactory (signature change) - Was: ``Callable[[], Any]`` (zero-arg). - Now: ``Callable[[SubAgentBuildContext], Pipeline | Awaitable[Pipeline]]``. - _resolve_pipeline(factory, ctx) calls factory(ctx); on TypeError it falls back to factory() so pre-D1 zero-arg fixtures keep working. SubagentTypeOrchestrator._dispatch_one - Builds the ctx and passes it to the factory. - Surfaces descriptor.provider / parallel / max_concurrent on the sub_result.subagent_metadata so UI/audit layers can render the new fields without re-walking the registry. s12_agent/__init__.py exports PipelineFactory + SubAgentBuildContext. Tests - tests/unit/test_subagent_descriptor.py (NEW) — 9 cases: new fields, frozen, ctx population (provider + parent ids + credentials + workspace), legacy zero-arg factory fallback, sub_result metadata. - Existing tests/unit/test_subagent_type_orchestrator.py — 19 pass (legacy zero-arg fixtures keep working). Full suite: 3214 passed, 8 skipped, 0 failed. Plan reference: docs/llm-backend-upgrade-plan/07_rollout_phases.md (Phase D1). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Summary
Phase D1 of the LLM backend upgrade cycle. Unblocks multi-provider sub-agents by handing a build context to every factory — the descriptor's provider choice + the parent's `CredentialBundle` flow down so a sub-pipeline's Stage 6 can authenticate against any of the 6 registered providers.
What's new
Test plan
Plan reference: `docs/llm-backend-upgrade-plan/07_rollout_phases.md` (Phase D1).