Skip to content

fix(agent-core): make delegation schemas provider-safe - #17

Merged
boh5 merged 2 commits into
mainfrom
codex/system-qa
Aug 10, 2026
Merged

fix(agent-core): make delegation schemas provider-safe#17
boh5 merged 2 commits into
mainfrom
codex/system-qa

Conversation

@boh5

@boh5 boh5 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • project portable, role/depth-aware delegate and skill_list schemas at the model boundary
  • add target-aware bounded Skill discovery with recovery-safe authorization
  • unify fresh and resumed delegation admission with stable typed errors and zero-child rejection

Root cause

Strict internal Skill-name regexes and static delegation contracts were being exposed directly to Providers. The default Provider rejected the regex lookaround before model execution, while target/Profile/Skill authority was split across multiple runtime paths.

Validation

  • bun run typecheck
  • bun run test
  • bun run build
  • git diff --check
  • real default-model browser QA: Discussion, Todo Work, Direct Session, Automation, plus full service restart
  • independent gpt-5.6-sol(max) review: PASS

Review in cubic

Summary by CodeRabbit

  • New Features
    • Improved agent delegation with capability-aware target, profile, depth, and skill authorization.
    • Added targeted skill discovery for current and delegated agents.
    • Added portable tool schemas for improved model and provider compatibility.
  • Bug Fixes
    • Prevented unauthorized targets and skills from being exposed or executed.
    • Revalidated permissions when resuming delegated sessions.
    • Improved delegation errors with specific failure categories.
  • Documentation
    • Added planning and progress documentation for provider-safe delegation and skill contracts.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Delegation authority now uses immutable target, profile, Skill, parent, and depth snapshots. Model-facing schemas are projected from those capabilities. Skill discovery supports authorized target catalogs. Session creation, resume, and recovery validate capabilities before exposing Skills or creating child state.

Delegation and Skill contract updates

Layer / File(s) Summary
Capability snapshots and model projection
packages/agent-core/src/agents/*
The factory resolves immutable delegation snapshots and supplies them to ConfiguredAgent. Prompt metadata and projected delegate and Skill tools use those snapshots.
Provider schemas and target Skill discovery
packages/agent-core/src/delegation/*, packages/agent-core/src/tools/builtins/*, packages/agent-core/src/agents/query/*
Portable model schemas separate presentation from execution validation. skill_list resolves current-Agent and authorized target catalogs. skill_read exposes a strict model-facing JSON schema.
Delegation admission and recovery validation
packages/agent-core/src/execution/*, packages/agent-core/src/tools/builtins/delegate.*
Session execution validates target, profile, depth, and Skill capabilities before child creation and during resume. Delegate failures map to stable tool error codes. Recovery tests cover authorization rebuild and fail-closed behavior.

Possibly related PRs

  • boh5/archcode#11: Shares factory changes for root agent creation and delegation capability setup.
  • boh5/archcode#14: Shares SkillService, Skill discovery, and delegated Skill validation changes.
  • boh5/archcode#15: Shares delegation and Skill capability resolution changes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making agent-core delegation schemas provider-safe.
Description check ✅ Passed The description explains the change, root cause, validation, and security-relevant behavior, but omits explicit Documentation and Related issue sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/agent-core/src/agents/configured-agent.test.ts`:
- Around line 273-286: Align the test helper’s delegation target condition with
the runtime factory: require the resolved `delegate` capability/tool to be
allowed before building delegationTargets. Update the canDelegate logic around
options.definition.childPolicy and defaultAgentDefinitions so missing or
unresolvable delegate configuration produces no targets and preserves
fail-closed behavior.

In `@packages/agent-core/src/tools/builtins/skill-list.test.ts`:
- Around line 225-230: Update the test named “input schema accepts delegated
targets and rejects unknown keys or roles” to assert that
SkillListInputSchema.safeParse rejects an input containing an unsupported field,
preserving the existing valid-target and invalid-role assertions and explicitly
covering the .strict() contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 12270338-1bc0-42c0-99ab-c6b64a442d5f

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2be9b and ec0f661.

📒 Files selected for processing (29)
  • AGENTS.md
  • docs/goals/provider-safe-delegation-skill-contract-plan-goal.md
  • docs/goals/provider-safe-delegation-skill-contract-progress.md
  • packages/agent-core/src/agents/configured-agent.test.ts
  • packages/agent-core/src/agents/configured-agent.ts
  • packages/agent-core/src/agents/constants.ts
  • packages/agent-core/src/agents/errors.ts
  • packages/agent-core/src/agents/factory-types.ts
  • packages/agent-core/src/agents/factory.test.ts
  • packages/agent-core/src/agents/factory.ts
  • packages/agent-core/src/agents/index.ts
  • packages/agent-core/src/agents/model-tool-projection.test.ts
  • packages/agent-core/src/agents/model-tool-projection.ts
  • packages/agent-core/src/agents/query/loop.ts
  • packages/agent-core/src/agents/query/types.ts
  • packages/agent-core/src/agents/session-agent-manager.test.ts
  • packages/agent-core/src/delegation/contract.test.ts
  • packages/agent-core/src/delegation/schema.ts
  • packages/agent-core/src/execution/session-execution-manager.test.ts
  • packages/agent-core/src/execution/session-execution-manager.ts
  • packages/agent-core/src/execution/session-tool-batch-scheduler.test.ts
  • packages/agent-core/src/tools/builtins/delegate.test.ts
  • packages/agent-core/src/tools/builtins/delegate.ts
  • packages/agent-core/src/tools/builtins/model-visible-contract.test.ts
  • packages/agent-core/src/tools/builtins/skill-list.test.ts
  • packages/agent-core/src/tools/builtins/skill-list.ts
  • packages/agent-core/src/tools/builtins/skill-read.test.ts
  • packages/agent-core/src/tools/builtins/skill-read.ts
  • packages/agent-core/src/tools/types.ts
💤 Files with no reviewable changes (2)
  • packages/agent-core/src/agents/constants.ts
  • packages/agent-core/src/agents/errors.ts

Comment thread packages/agent-core/src/agents/configured-agent.test.ts
Comment thread packages/agent-core/src/tools/builtins/skill-list.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/agent-core/src/runtime-skill-command.test.ts`:
- Around line 85-97: Update waitForFamilyIdle to check the session family’s
current activity immediately after subscribing by calling
runtime.getSessionFamilyActivity with workspaceRoot and rootSessionId. If the
result is "idle", unsubscribe and resolve the Promise; otherwise continue
waiting for the matching idle event, following the synchronous-check pattern
used in lead-architecture-flows.integration.test.ts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: be35ccc3-fe46-409a-b8dd-e2c7588b42c8

📥 Commits

Reviewing files that changed from the base of the PR and between ec0f661 and fc63eb2.

📒 Files selected for processing (2)
  • packages/agent-core/src/agents/configured-agent.test.ts
  • packages/agent-core/src/runtime-skill-command.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/agent-core/src/agents/configured-agent.test.ts

Comment thread packages/agent-core/src/runtime-skill-command.test.ts
@boh5
boh5 merged commit def4e32 into main Aug 10, 2026
7 checks passed
@boh5
boh5 deleted the codex/system-qa branch August 10, 2026 09:01
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