Skip to content

refactor(s12_agent): SubagentTypeDescriptor + SubAgentBuildContext + parameterized PipelineFactory#199

Merged
CocoRoF merged 1 commit into
mainfrom
feat/llm-backend/d1-subagent-descriptor
May 17, 2026
Merged

refactor(s12_agent): SubagentTypeDescriptor + SubAgentBuildContext + parameterized PipelineFactory#199
CocoRoF merged 1 commit into
mainfrom
feat/llm-backend/d1-subagent-descriptor

Conversation

@CocoRoF
Copy link
Copy Markdown
Owner

@CocoRoF CocoRoF commented May 17, 2026

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

  • `SubagentTypeDescriptor` gains `provider`, `provider_credentials_extras`, `parallel`, `max_concurrent`.
  • `SubAgentBuildContext` (new frozen dataclass) — parent/sub session ids + credentials + descriptor + workspace_snapshot + parent_state_shared.
  • `PipelineFactory` signature changes from `Callable[[], Any]` to `Callable[[SubAgentBuildContext], Pipeline | Awaitable[Pipeline]]`.
  • `_resolve_pipeline(factory, ctx)` with TypeError fallback so legacy zero-arg factories keep working until callers migrate.
  • `SubagentTypeOrchestrator._dispatch_one` populates a ctx and forwards descriptor.provider / parallel / max_concurrent into `sub_result.subagent_metadata`.

Test plan

  • `tests/unit/test_subagent_descriptor.py` (NEW) — 9 cases: new fields, frozen, ctx propagation, legacy zero-arg factory fallback, metadata surfacing.
  • `tests/unit/test_subagent_type_orchestrator.py` — 19 pre-existing cases pass unchanged.
  • Full repo: 3214 passed, 8 skipped, 0 failed.

Plan reference: `docs/llm-backend-upgrade-plan/07_rollout_phases.md` (Phase D1).

…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>
@CocoRoF CocoRoF merged commit d592273 into main May 17, 2026
@CocoRoF CocoRoF deleted the feat/llm-backend/d1-subagent-descriptor branch May 17, 2026 13:23
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.

1 participant