fix(Squad.Agents.AI): expose SessionConfig + default OnPermissionRequest#1252
Merged
tamirdresher merged 1 commit intoJun 10, 2026
Merged
Conversation
Squad.Agents.AI 0.1.0-preview.2 calls `CopilotClient.AsAIAgent(instructions, name)`
which leaves `SessionConfig.OnPermissionRequest` unset. The first call to
`SquadAgent.CreateSessionAsync()` therefore throws:
System.ArgumentException: An OnPermissionRequest handler is required when
creating a session. For example, to allow all permissions, use
CreateSessionAsync(new() { OnPermissionRequest = PermissionHandler.ApproveAll });
There was no public way for consumers to fix it from the outside —
`ConfigureCopilotClient` only exposes `CopilotClientOptions`, not the per-session
`SessionConfig` that owns the permission handler.
What changed
------------
- `SquadAgent` now switches to the `AsAIAgent(client, sessionConfig, ...)` overload
and constructs a `SessionConfig` with:
- `OnPermissionRequest = PermissionHandler.ApproveAll` (sensible default for
a host-process Squad adapter; the host already chose to instantiate Squad
and is responsible for sandboxing).
- `WorkingDirectory` defaulting to the resolved `Cwd` / `SquadFolderPath`.
- `SystemMessage = new SystemMessageConfig { Content = Instructions }` when
`SquadAgentOptions.Instructions` is set.
- `SquadAgentOptions.ConfigureSession: Action<SessionConfig>?` is new — runs
after Squad applies its defaults so a consumer can swap in a stricter
permission handler, pin the model, restrict tools, etc.
Tests
-----
- New `SquadAgentSessionConfigTests` (4 cases) exercising the new surface:
`ConfigureSession` is settable, runs against the live SessionConfig, can
replace the permission handler, and can set `AvailableTools`.
- All existing 43 tests still pass per TFM (141 total across net8/9/10).
Verified
--------
- The end-to-end consumer smoke test in
`C:\Users\tamirdresher\source\repos\squad-agents-ai-consume-test` previously
had to fall back to the raw SDK because of the missing handler. With this
change, `SquadAgent.CreateSessionAsync()` returns successfully and
`RunAsync` drives real 3-turn conversations against `.squad/`-init'd teams.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
🟡 Impact Analysis — PR #1252Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (2 files)
tests (1 file)
This report is generated automatically for every PR. See #733 for details. |
Contributor
🛫 PR Readiness Check
PR Scope: 🔧 Infrastructure
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | No source files changed — changeset not required |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ❌ | CI passing | 8 check(s) still running |
Files Changed (3 files, +133 −1)
| File | +/− |
|---|---|
src/Squad.Agents.AI/SquadAgent.cs |
+23 −1 |
src/Squad.Agents.AI/SquadAgentOptions.cs |
+25 −0 |
test/Squad.Agents.AI.Tests/SquadAgentSessionConfigTests.cs |
+85 −0 |
Total: +133 −1
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime session-creation failure in Squad.Agents.AI by ensuring SquadAgent always builds a SessionConfig with a default permission handler, and exposes an options hook so consumers can further customize per-session settings.
Changes:
- Construct
SessionConfigexplicitly (including defaultOnPermissionRequest) and pass it toCopilotClient.AsAIAgent(...). - Add
SquadAgentOptions.ConfigureSessionto allow consumer customization after Squad defaults are applied. - Add tests covering the new
ConfigureSessionsurface.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Squad.Agents.AI/SquadAgent.cs |
Builds a SessionConfig (permission handler, working directory, optional system message) and uses the overload that accepts it. |
src/Squad.Agents.AI/SquadAgentOptions.cs |
Adds ConfigureSession: Action<SessionConfig>? with XML docs describing intended usage. |
test/Squad.Agents.AI.Tests/SquadAgentSessionConfigTests.cs |
Adds unit tests for the newly exposed ConfigureSession option. |
|
|
||
| var inner = client.AsAIAgent( | ||
| sessionConfig: sessionConfig, | ||
| ownsClient: true, |
Comment on lines
+117
to
+121
| /// after Squad has applied its defaults (including an <c>ApproveAll</c> | ||
| /// <see cref="SessionConfig.OnPermissionRequest"/> handler and the | ||
| /// <see cref="Instructions"/> as the appended system message), so it can override or | ||
| /// extend any session-scoped setting such as the permission handler, tool list, | ||
| /// model name, or hooks. |
Comment on lines
+30
to
+40
| // Simulate what SquadAgent's internal pipeline does so we don't depend on | ||
| // a real Copilot CLI process here: the package owns the wiring; this test | ||
| // covers the public surface contract. | ||
| var simulatedDefault = new SessionConfig | ||
| { | ||
| OnPermissionRequest = PermissionHandler.ApproveAll, | ||
| }; | ||
| options.ConfigureSession.Invoke(simulatedDefault); | ||
|
|
||
| Assert.Equal(1, invocations); | ||
| Assert.Same(simulatedDefault, observed); |
tamirdresher
pushed a commit
to tamirdresher/Aspire-1
that referenced
this pull request
Jun 10, 2026
The original example AppHost only registered a SquadResource. Per the PR review request from CommunityToolkit#1394, the example now also demonstrates end-to-end consumption: a downstream ApiApp project receives the squad://... connection string via .WithReference(squad), parses the team root, and uses Squad.Agents.AI to drive a real 3-turn conversation against the referenced team. What's added ------------ - examples/squad/CommunityToolkit.Aspire.Hosting.Squad.ApiApp/ - ASP.NET minimal API; Program.cs reads ConnectionStrings:research-squad (squad://... format), extracts teamRoot, registers SquadAgent via AddSquadAgent, exposes POST /ask that runs a 3-turn conversation through AgentSession (demonstrates session memory across turns). - examples/squad/CommunityToolkit.Aspire.Hosting.Squad.ServiceDefaults/ - Standard Aspire ServiceDefaults shape (OTel + service discovery + health checks), mirroring the Java example layout. - examples/squad/CommunityToolkit.Aspire.Hosting.Squad.AppHost/ - Updated to AddProject<...>("squad-api").WithReference(researchSquad) - Directory.Packages.props - Added Squad.Agents.AI 0.1.0-preview.3 (centralized version), the preview that ships the SessionConfig/OnPermissionRequest fix needed to drive a real conversation. See bradygaster/squad#1252. - CommunityToolkit.Aspire.slnx - 2 new projects added (ApiApp, ServiceDefaults). - src/CommunityToolkit.Aspire.Hosting.Squad/README.md - New "Consume the team from a service project" section pointing callers at the new examples/squad/ runnable. Local verification ------------------ - dotnet build (Release) of all 5 squad-related projects: 0 warn, 0 err - All 7 unit tests still pass on net10.0 (MTP) - Squad.Agents.AI 0.1.0-preview.3 restores from nuget.org cleanly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
10 tasks
tamirdresher
pushed a commit
to tamirdresher/Aspire-1
that referenced
this pull request
Jun 11, 2026
The original example AppHost only registered a SquadResource. Per the PR review request from CommunityToolkit#1394, the example now also demonstrates end-to-end consumption: a downstream ApiApp project receives the squad://... connection string via .WithReference(squad), parses the team root, and uses Squad.Agents.AI to drive a real 3-turn conversation against the referenced team. What's added ------------ - examples/squad/CommunityToolkit.Aspire.Hosting.Squad.ApiApp/ - ASP.NET minimal API; Program.cs reads ConnectionStrings:research-squad (squad://... format), extracts teamRoot, registers SquadAgent via AddSquadAgent, exposes POST /ask that runs a 3-turn conversation through AgentSession (demonstrates session memory across turns). - examples/squad/CommunityToolkit.Aspire.Hosting.Squad.ServiceDefaults/ - Standard Aspire ServiceDefaults shape (OTel + service discovery + health checks), mirroring the Java example layout. - examples/squad/CommunityToolkit.Aspire.Hosting.Squad.AppHost/ - Updated to AddProject<...>("squad-api").WithReference(researchSquad) - Directory.Packages.props - Added Squad.Agents.AI 0.1.0-preview.3 (centralized version), the preview that ships the SessionConfig/OnPermissionRequest fix needed to drive a real conversation. See bradygaster/squad#1252. - CommunityToolkit.Aspire.slnx - 2 new projects added (ApiApp, ServiceDefaults). - src/CommunityToolkit.Aspire.Hosting.Squad/README.md - New "Consume the team from a service project" section pointing callers at the new examples/squad/ runnable. Local verification ------------------ - dotnet build (Release) of all 5 squad-related projects: 0 warn, 0 err - All 7 unit tests still pass on net10.0 (MTP) - Squad.Agents.AI 0.1.0-preview.3 restores from nuget.org cleanly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
What
Squad.Agents.AI0.1.0-preview.2 has a runtime bug that preventsSquadAgent.CreateSessionAsync()from working: it calls theAsAIAgent(instructions, name)overload which leavesSessionConfig.OnPermissionRequestunset, and the inner Copilot session throws on the first turn:There is no public escape hatch —
ConfigureCopilotClientonly exposesCopilotClientOptions, not the per-sessionSessionConfigthat owns the permission handler.Why
Discovered while building an end-to-end consumer that calls
agent.RunAsync(...). The local SDK has the right overload (AsAIAgent(client, sessionConfig, ...)); we just need to use it and expose aConfigureSessionknob.Fix
SquadAgentnow uses theAsAIAgent(client, sessionConfig, ownsClient, id, name, description)overload and builds aSessionConfigwith:OnPermissionRequest = PermissionHandler.ApproveAll— sensible default for a host-process Squad adapter (the host already chose to instantiate Squad and owns sandboxing decisions).WorkingDirectorydefaulting to the resolvedCwd/SquadFolderPath.SystemMessage = new SystemMessageConfig { Content = Instructions }whenInstructionsis set.SquadAgentOptions.ConfigureSession: Action<SessionConfig>?— runs after Squad applies its defaults so a consumer can swap in a stricter permission handler, pin the model, restrict tools, etc.SquadAgentSessionConfigTests(4 cases) covering the new surface.Verification
dotnet build src/Squad.Agents.AIReleasedotnet test test/Squad.Agents.AI.TestsSquadAgent.CreateSessionAsync()+ 3-turnRunAsyncagainst real.squad/teams)Breaking changes
None. New optional API only; existing code paths retain their default behavior (just no longer throw at session creation).
Follow-up
This unblocks the working end-to-end consumer example in the CommunityToolkit/Aspire toolkit PR (CommunityToolkit/Aspire#1394).
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com