Skip to content

refactor(agents): require one resolved capability profile per run#99817

Merged
steipete merged 1 commit into
mainfrom
refactor/require-capability-profile
Jul 4, 2026
Merged

refactor(agents): require one resolved capability profile per run#99817
steipete merged 1 commit into
mainfrom
refactor/require-capability-profile

Conversation

@steipete

@steipete steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The final bundled-tool policy pass and the attempt allowlist-source readout now consume the run's single resolved conversation capability profile instead of optionally re-resolving their own.

  • applyFinalEffectiveToolPolicy (src/agents/embedded-agent-runner/effective-tool-policy.ts): conversationCapabilityProfile is required; the ~15 raw identity params (sessionKey, agentId, group/sender fields, model refs, sandboxToolPolicy) and the silent fallback re-resolution are deleted. The sandbox pipeline step reads policy.sandboxPolicy from the profile.
  • collectAttemptExplicitToolAllowlistSources (src/agents/embedded-agent-runner/run/attempt.ts): same contract; it now reports allowlist sources from the profile that actually constructed and filtered the run's tools. Previously the callsite omitted the profile, so the fallback resolved a second full profile per attempt with divergent inputs — policy/group trust keyed off the live session key while tool construction used the sandbox policy session key. Where those keys differ, the reported sources could disagree with enforcement; they can no longer.
  • Embedded attempt and compaction thread one runtimeCapabilityProfile into tool construction, the final bundled pass, and allowlist sources; the redundant raw-param forwarding blocks at those callsites are gone.
  • Doctor runtime checks (src/flows/doctor-core-checks.runtime.ts) and gateway tools.effective (src/gateway/server-methods/tools-effective.ts) resolve their config-scope profile explicitly at the callsite — same inputs as before, resolution now visible instead of implicit.
  • createOpenClawCodingTools keeps its optional profile param and self-resolve: it is public plugin-SDK surface (src/plugin-sdk/agent-harness.ts). applyFinalEffectiveToolPolicy is not SDK-exported (verified), so its signature change is internal.

Net: one canonical profile resolution per embedded run, enforced by the type system rather than by convention; +95/-176.

Proof (local)

  • pnpm tsgo clean.
  • pnpm vitest run on effective-tool-policy.test.ts, agent-bundle-mcp-tools.request-boundary.test.ts, gateway tools-effective suites, tool-allowlist-guard.test.ts, doctor runtime suites, attempt tool-plan suites — all green (77 + 44 + 33 across batches; suite tests updated to the resolve-then-apply composition mirroring production).
  • oxfmt --check clean on touched files.

Non-goals

  • No behavior change to policy pipeline ordering, tool filtering semantics, or the SDK surface.
  • Harness selection (src/agents/harness/selection.ts) still resolves per entry point; threading the attempt profile there needs the btw.ts call-chain reshaped and is left as follow-up.

applyFinalEffectiveToolPolicy and collectAttemptExplicitToolAllowlistSources
took ~15 raw identity params each and silently re-resolved a second
capability profile when callers forgot to pass one — with divergent
session inputs (attempt allowlist sources resolved policy off the live
session key while tool construction used the sandbox policy key). The
profile param is now required, the fallback resolution stacks are
deleted, and the attempt threads its single resolved profile into tool
construction, the final bundled pass, and allowlist sources. Doctor and
gateway tools.effective callers resolve their config-scope profile
explicitly at the callsite. createOpenClawCodingTools keeps its optional
self-resolve as public plugin-SDK convenience.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 4, 2026
@clawsweeper

clawsweeper Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: refactor(agents): require one resolved capability profile per run This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33ebb71c3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

modelId: params.modelId,
sandboxToolPolicy: params.sandboxToolPolicy,
});
const capabilityProfile = params.conversationCapabilityProfile;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Update dist E2E callers for required profile

When scripts/e2e/agent-bundle-mcp-tools-docker.sh runs the in-container harness, test/e2e/qa-lab/runtime/agent-bundle-mcp-tools-docker-client.ts still calls applyFinalEffectiveToolPolicy with only sessionKey/agentId/senderIsOwner. Because this new contract leaves params.conversationCapabilityProfile undefined and the next line dereferences .policy for any non-empty MCP tool list, that packaged Docker smoke now throws before verifying bundled MCP policy instead of using the previous self-resolve fallback. Please update that dist-only caller to resolve/pass the profile, or keep a compatibility path for existing untyped internal callers.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 79d2e56 into main Jul 4, 2026
142 of 147 checks passed
@steipete
steipete deleted the refactor/require-capability-profile branch July 4, 2026 09:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 5, 2026
…enclaw#99817)

applyFinalEffectiveToolPolicy and collectAttemptExplicitToolAllowlistSources
took ~15 raw identity params each and silently re-resolved a second
capability profile when callers forgot to pass one — with divergent
session inputs (attempt allowlist sources resolved policy off the live
session key while tool construction used the sandbox policy key). The
profile param is now required, the fallback resolution stacks are
deleted, and the attempt threads its single resolved profile into tool
construction, the final bundled pass, and allowlist sources. Doctor and
gateway tools.effective callers resolve their config-scope profile
explicitly at the callsite. createOpenClawCodingTools keeps its optional
self-resolve as public plugin-SDK convenience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant