Skip to content

Link forked skills to their Skill call and finish them - #39

Merged
JasonPierce merged 6 commits into
mainfrom
forked-skills
Nov 14, 2026
Merged

JasonPierce merged 6 commits into
mainfrom
forked-skills

Conversation

@JasonPierce

Copy link
Copy Markdown
Contributor

A skill run with context: fork showed up as a sub-agent of the session's root instead of the Skill call that started it. On Claude Code 2.1.317 through 2.1.323 it also never finished, so its lane stayed open and its status stuck: one read thinking an hour after its call returned. The fork's meta names no call, and antfarm only linked sub-agents through a meta's toolUseId or an async Agent result.

The Skill result names the fork (status: "forked", agentId), so antfarm now links the fork to the call and the calling agent there. A foreground fork, which is what 2.1.323 and earlier write, is finished at that result. While one runs, its meta is linked to the session's one open Skill call that has no fork yet and started before the fork's transcript was written, and the result confirms or replaces that link. leaf_agent now follows any open call with a live linked child, so a running fork's permission prompt is shown on the fork's own call rather than on the root's Skill call. Backfill batches carry fork links too, so forks older than the 16 MB tail are fixed as well.

A live repro turned up a change in 2.1.325: the Skill result now has background: true and returns at once, and the fork finishes later through finished: true in its meta and a task notification. Across 91 forked results from 2.1.317 to 2.1.323 none had background, and the 2.1.325 one did. Background forks are linked at the result and finish on their own, like an async Agent.

Done when

  • A forked result links the agent to the call and the calling agent, and finishes it at the result's time: a_forked_result_links_and_finishes_its_fork in subagents.rs. Background forks: a_background_fork_is_linked_at_its_result_and_finished_by_its_notification.
  • A fork whose meta appears before the result is re-parented without a duplicate agent or a second spawn mark: a_running_fork_is_linked_to_the_open_skill_call_and_is_the_leaf (one spawn mark after the result), with_two_open_skill_calls_the_fork_waits_for_its_result, and a_wrong_running_link_is_replaced_by_the_result. a_workflow_agent_or_an_old_fork_is_not_taken_for_a_running_fork covers metas that must not match: workflow agents, and old forks read at attach.
  • A fork started by a sub-agent goes under that sub-agent: a_fork_started_by_a_sub_agent_goes_under_it.
  • An end-to-end test on a scrubbed, captured fixture: real_forked_skill in crates/antfarm-core/tests/fixtures.rs, on fixtures/real/forked-skill captured with capture-fixture from a throwaway Haiku session with a scratch context: fork skill. It isn't from a real project. It sits with the other fixture tests instead of in subagents.rs, and the unit tests there cover the foreground path, which 2.1.325 no longer writes. The scrubber was renaming the background key inside toolUseResult; it's now kept, with a test.
  • DESIGN.md section 3.3 describes forked skills and the meta fields they lack, including the 2.1.325 change and its new forked-skill.json and forked-skill.marker.json files, which antfarm doesn't read.

Backfill: a_backfilled_fork_link_links_and_finishes_it and the decoder's a_forked_skill_result_becomes_a_fork_link.

Checked by hand

live-repro on Claude Code 2.1.325 with Haiku, main against the branch, running a forked scratch skill that sleeps 12 seconds. While it ran, main showed the fork under the root with no spawned_by, and the branch showed it under the Skill call. After it finished, both marked it finished at the same time, from the meta and the notification, and only the branch had it linked. The app's recorded screens are unchanged when regenerated.

Not checked

  • A live foreground fork, because 2.1.325 doesn't write one. That path is covered by unit tests built from the shapes seen in 2.1.317 to 2.1.323 transcripts on this machine, which I didn't capture because they're client work.
  • A fork's permission prompt shown live, since the session ran in auto mode. The leaf change is covered by a_running_fork_is_linked_to_the_open_skill_call_and_is_the_leaf.

Closes #36

@JasonPierce

Copy link
Copy Markdown
Contributor Author

CI's check failed on the_flag_off_leaves_history_partial from #37, not on this change: its first snapshot landed after one call (right: 1) while the runner was still reading the other tails, and it had 11 by the time it compared. The test now waits until the call count stops changing and then checks that it holds; that's in f198984.

@JasonPierce

Copy link
Copy Markdown
Contributor Author

The next run timed out in two more of #37's tests, the move and progress ones: their slow mode paused after every 4 KB chunk, about 600 pauses, and the runner only got halfway through the 2.4 MB fixture in 20 s (read: 1304166, total: 2411562). 56680fc uses 64 KB chunks, about 40 pauses, and a 60 s wait. The file now runs in 2.5 s here, and in 5.5 s at background CPU priority.

@JasonPierce
JasonPierce merged commit 3ef2acf into main Nov 14, 2026
7 checks passed
@JasonPierce
JasonPierce deleted the forked-skills branch November 14, 2026 22:44
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.

Link forked skills to their Skill call and finish them when it returns

1 participant