fix(ci): sync concurrency/schedule/timeout guards to all 4 heartbeat templates (#4702) - #5
tamirdresher wants to merge 4 commits into
Conversation
…t OTel Adds a "subagent dispatched" envelope to the SquadSubagentTraceMapper so consumers and OTel backends see the LLM-supplied persona identity from the moment the coordinator invokes the `task` tool — instead of waiting for the later SubagentStartedEvent (which only carries the catalog `agent_type`, e.g. always "general-purpose"). Mapper / public surface: - Add `SubagentDispatched` to `SquadAgentTraceEventKind` and four persona properties on `SquadAgentTraceEvent` (`DispatchedPersonaName/Description/AgentType/Prompt`). - Rewrite mapper to key live activities by `ToolCallId` (primary) and maintain a `SdkAgentId → ToolCallId` lookup so `AssistantMessageEvent`s (which only carry `AgentId`) can find the right span. Activities are opened on the task-dispatch event and labelled with the persona name from the start, then augmented on `SubagentStartedEvent`. - Surface `AssistantMessageData.ToolRequests[].Name` on the typed envelope as `RequestedToolNames`, and add a `squad.subagent.tool_requests` ActivityEvent so tool-only assistant turns (empty Content) are visible on the OTel span as "called gh, view, grep" instead of a blank marker. Sample: - Add Flow 5 demonstrating both the typed `OnSubagentTrace` callback and an `ActivityListener` for OTel. - Update Flow 1 to use the same handler with the new tool-name surfacing and a short `ShortId` formatter so parallel subagents are visually distinct. - Fix Flow 3 (BYOK): merge the parent process env with custom vars to avoid the `Assertion failed: ncrypto::CSPRNG(nullptr, 0)` Node crash on Windows. SDK: - When forwarding `options.Environment` to the Copilot client, merge with the parent process env (instead of replacing it) so the native CLI inherits SYSTEMROOT/PATH/TEMP and doesn't crash on crypto init. Tests (82 total, all pass on net8.0/net9.0/net10.0): - 11 new tests covering task-dispatch parsing, `subagent_type` alias, bare-arguments fallback, `ToolRequests` extraction, the `squad.subagent.tool_requests` ActivityEvent, ToolCallId-keyed activity lifecycle, parallel dispatches, missing-arguments path, and the `sessionConfig.Agent = "Squad"` routing assertion update. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SquadSubagentTraceMapper: - Use TryAdd (with dispose-on-conflict) instead of indexer assignment when registering activities in _activitiesByToolCallId, in both the SubagentStarted and OnTaskDispatch paths. Indexer assignment could overwrite a previously-registered Activity for the same ToolCallId (e.g. when SubagentStartedEvent races OnTaskDispatch), leaking the prior Activity and breaking the 1-dispatch -> 1-span invariant. - Remove _personasByToolCallId and the DispatchedPersona record. The dictionary was only ever written, removed, or cleared - never read - so it was dead state. The persona is already attached to the activity directly (SetTags + ActivityEvent) and to the SubagentDispatched envelope, so removing the stash does not lose any data. SquadAgent / SquadAgentOptions: - Replace hardcoded SessionConfig.Agent = "Squad" with options.SessionAgent. Adds a new SessionAgent property on SquadAgentOptions, defaulting to "Squad" to preserve existing behavior (the existing SquadAgentRoutingTests still pass unchanged). Hosts that populate CopilotClientOptions.CustomAgents with a different identifier can now opt in; hosts that want the SDK's own default can set it to null. Sample (Program.cs): - Replace the machine-specific Windows path on Flow 1 with the existing teamRoot variable so the sample matches the other four flows and runs on any developer machine / CI without edits. Verified: dotnet test all 3 TFMs (net8.0/9.0/10.0) — 82/82 pass on each.
…tes (#4702) Add missing guards to both source templates so squad upgrade carries them forward to installed repos: - Add concurrency block (group: squad-heartbeat, cancel-in-progress: true) positioned after on: block - Add schedule trigger: cron '*/15 * * * *' for periodic triage sweep - Add timeout-minutes: 10 to heartbeat job Without these, squad upgrade silently drops the concurrency group that was manually added on 2026-05-24, causing 13 concurrent CI failures (issue #4699 in tamirdresher/tamresearch1). Active workflow was fixed in c5aca30c; these templates are the source-of-truth for future upgrades.
…emplates (#4702) Prior commit (6e253de) fixed templates/ and packages/squad-cli/templates/ but missed two additional template locations. Both are now in sync: - packages/squad-sdk/templates/workflows/squad-heartbeat.yml - .squad-templates/workflows/squad-heartbeat.yml Guards added to both: - concurrency: group: squad-heartbeat, cancel-in-progress: true - schedule: cron '*/15 * * * *' - timeout-minutes: 10 All 4 template locations now carry the same guards as the active workflow. CHANGELOG.md updated with Unreleased entry.
🟠 Impact Analysis — PR #5Risk tier: 🟠 HIGH 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (9 files)
squad-cli (1 file)
squad-sdk (1 file)
templates (1 file)
tests (2 files)
This report is generated automatically for every PR. See #733 for details. |
🛫 PR Readiness Check
PR Scope: 🔧 Infrastructure
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 4 commits — consider squashing before review |
| ✅ | 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 | CHANGELOG.md edit found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | No Copilot review threads |
| ✅ | CI passing | All checks passing |
Files Changed (14 files, +1316 −226)
| File | +/− |
|---|---|
.squad-templates/workflows/squad-heartbeat.yml |
+178 −167 |
CHANGELOG.md |
+3 −0 |
packages/squad-cli/templates/workflows/squad-heartbeat.yml |
+11 −0 |
packages/squad-sdk/templates/workflows/squad-heartbeat.yml |
+11 −0 |
src/Squad.Agents.AI/Squad.Agents.AI.csproj |
+1 −1 |
src/Squad.Agents.AI/SquadAgent.cs |
+22 −2 |
src/Squad.Agents.AI/SquadAgentDiagnostics.cs |
+53 −0 |
src/Squad.Agents.AI/SquadAgentOptions.cs |
+19 −0 |
src/Squad.Agents.AI/SquadSubagentTraceMapper.cs |
+309 −47 |
src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Program.cs |
+235 −7 |
src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Squad.Agents.AI.Sample.csproj |
+1 −1 |
templates/workflows/squad-heartbeat.yml |
+11 −0 |
test/Squad.Agents.AI.Tests/SquadAgentRoutingTests.cs |
+7 −1 |
test/Squad.Agents.AI.Tests/SquadSubagentTraceTests.cs |
+455 −0 |
Total: +1316 −226
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
|
👋 Friendly nudge — this PR has had no activity for 9 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
7 similar comments
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
|
👋 Friendly nudge — this PR has had no activity for 7 days. What needs attention:
If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows. |
Summary
Fixes tamirdresher/tamresearch1#4702
On 2026-07-09, a \squad upgrade\ silently dropped the concurrency guard that was added to the active heartbeat workflow on 2026-05-24, causing 13 concurrent CI failures (tamirdresher/tamresearch1#4699). The guard was already present in 2 of 4 template locations (added in commit 6e253de), but 2 locations were still missing all 3 guards.
This PR completes the fix by syncing all 3 guards to the remaining template locations.
Files Changed
Guards Added (to squad-sdk and .squad-templates)
\\yaml
schedule trigger added to on: block
schedule:
concurrency block added after on: block
concurrency:
group: squad-heartbeat
cancel-in-progress: true
timeout-minutes added to job
timeout-minutes: 10
\\
Why This Matters
Every \squad upgrade\ reads templates and writes the result to installed repos. Without these guards in every template location, a future upgrade will again silently drop the concurrency group — causing the same CI storm that triggered tamirdresher/tamresearch1#4699.
CHANGELOG
Added entry to [Unreleased]\ section documenting all 4 template locations now being in sync.