Skip to content

fix(ci): sync concurrency/schedule/timeout guards to all 4 heartbeat templates (#4702) - #5

Open
tamirdresher wants to merge 4 commits into
devfrom
squad/4702-heartbeat-template-sync
Open

tamirdresher wants to merge 4 commits into
devfrom
squad/4702-heartbeat-template-sync

Conversation

@tamirdresher

Copy link
Copy Markdown
Owner

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

Template location Before After
\ emplates/workflows/squad-heartbeat.yml\ ✅ Already fixed (6e253de)
\packages/squad-cli/templates/workflows/squad-heartbeat.yml\ ✅ Already fixed (6e253de)
\packages/squad-sdk/templates/workflows/squad-heartbeat.yml\ ❌ Missing all 3 guards ✅ Fixed here
.squad-templates/workflows/squad-heartbeat.yml\ ❌ Missing all 3 guards ✅ Fixed here

Guards Added (to squad-sdk and .squad-templates)

\\yaml

schedule trigger added to on: block

schedule:

  • cron: "*/15 * * * *"

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.

tamirdresher and others added 4 commits June 24, 2026 14:19
…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.
@github-actions

Copy link
Copy Markdown

🟠 Impact Analysis — PR #5

Risk tier: 🟠 HIGH

📊 Summary

Metric Count
Files changed 14
Files added 0
Files modified 14
Files deleted 0
Modules touched 5

🎯 Risk Factors

  • 14 files changed (6-20 → MEDIUM)
  • 5 modules touched (5-8 → HIGH)

📦 Modules Affected

root (9 files)
  • CHANGELOG.md
  • src/Squad.Agents.AI/Squad.Agents.AI.csproj
  • src/Squad.Agents.AI/SquadAgent.cs
  • src/Squad.Agents.AI/SquadAgentDiagnostics.cs
  • src/Squad.Agents.AI/SquadAgentOptions.cs
  • src/Squad.Agents.AI/SquadSubagentTraceMapper.cs
  • src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Program.cs
  • src/Squad.Agents.AI/samples/Squad.Agents.AI.Sample/Squad.Agents.AI.Sample.csproj
  • templates/workflows/squad-heartbeat.yml
squad-cli (1 file)
  • packages/squad-cli/templates/workflows/squad-heartbeat.yml
squad-sdk (1 file)
  • packages/squad-sdk/templates/workflows/squad-heartbeat.yml
templates (1 file)
  • .squad-templates/workflows/squad-heartbeat.yml
tests (2 files)
  • test/Squad.Agents.AI.Tests/SquadAgentRoutingTests.cs
  • test/Squad.Agents.AI.Tests/SquadSubagentTraceTests.cs

This report is generated automatically for every PR. See #733 for details.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 1177c05

PR Scope: 🔧 Infrastructure

⚠️ 2 item(s) to address before review

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.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 9 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

7 similar comments
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

@github-actions

Copy link
Copy Markdown

👋 Friendly nudge — this PR has had no activity for 7 days.

What needs attention:

  • 👀 No approving reviews yet. Request a review from a teammate.

If this PR is abandoned, please close it. If it's blocked on something external, leave a comment so the team knows.
This is an automated check that runs on weekdays. It won't nudge the same PR more than once per week.

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