Skip to content

Fit the connector's per-request steps inside the compaction cut - #890

Merged
jeremy merged 8 commits into
mainfrom
connect-skill-subagent-file
Oct 13, 2026
Merged

jeremy merged 8 commits into
mainfrom
connect-skill-subagent-file

Conversation

@jeremy

@jeremy jeremy commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

basecamp-connect now leads with the steps each request needs, and the subagent's instructions move to skills/basecamp-connect/subagent.md. The subagent reads that file itself.

Why

Change

  • New order:
    1. Intro
    2. Running the connector (start and watch, then the request line)
    3. For each request (a. acknowledge, b. choose the repo, c. dispatch)
    4. Then rules, invocation, first-time setup, stopping and checking
  • Rules, invocation and setup matter at start, when the whole file is in context.
  • subagent.md is the former "The subagent's instructions" section. It inlines the boost loop it used to reach "as above".
  • The handoff passes the file's path and tells the subagent to read it in full first. The orchestrator no longer pastes ~4.3k tokens into every dispatch.
  • Two cross-references now point at subagent.md.
  • scripts/check-skill-drift.sh stripped everything before a second ---, so a file without frontmatter was skipped whole. It now strips frontmatter only when the file opens with one. make check-skill-drift checks subagent.md too.
  • internal/release/manifests_test.go requires subagent.md to ship.

Verification

  • Token counts from API usage (haiku, prompt with the text minus a baseline):
    • per-request part of the rendered body: 4,474 tokens
    • whole skill: 9,353 (main: 13,294)
    • subagent.md: 4,276
  • internal/connector/skill_layout_test.go:
    • The per-request steps end within 14,000 characters of the body, about 4,800 tokens at this file's ~2.9 chars/token, and come in order.
    • The subagent's steps live in subagent.md.
    • Both tests fail on main's skill.
  • make check-skill-drift passes: subagent.md has 12 commands and 23 flags validated, and appending a bogus command turns it red. make test-skill-drift, test-sync-skills, and go test ./internal/connector/ ./internal/release/ pass.
  • golangci-lint on this machine trips on a sibling worktree's file (../basecamp-cli-worktrees/security-ci-main/...), not on this diff.

Alternatives

  • Trimming prose to fit: the subagent text alone is ~4.3k tokens, so the order had to change anyway.
  • Keeping the subagent text in SKILL.md after the cut: the orchestrator would still paste it into every handoff and would need it after compaction. A file the subagent reads removes both costs.

Summary by cubic

Fits the basecamp-connect per-request steps within the 5,000-token cut Claude Code re-attaches after compaction. The skill ran ~13,300 tokens, so the cut fell before the handoff and a compacted orchestrator could acknowledge a request but never dispatch it.

  • Opens with start/watching, the request line, and acknowledge, choose-repo, dispatch; repo choice names ~/.config/basecamp-connect/last.json and its mapping shape. The post-as-the-agent rule joined the per-request part, which still posts a holding reply and a refusal itself and points at step 5 of subagent.md for the reply commands; the restart after a setup change stays before the cut. A connector change an owner asks for mid-run reads SKILL.md in full first, after the acknowledgement, since setup, stopping and checking sit past the cut, using the base directory as fallback if the placeholder reads literally. Rules, invocation, and first-time setup follow, and the skill drops to ~9,353 tokens.
  • Moves the subagent's instructions to subagent.md; the handoff passes ${CLAUDE_SKILL_DIR}/subagent.md, which Claude Code expands (with the skill's base directory as fallback if it reads literally), and tells the subagent to read it in full, so the orchestrator no longer pastes ~4.3k tokens into every handoff. The quoting rule joined the per-request window, since it sat past the cut while the boost still interpolated the acknowledgement, which would break on values like "I'm on it". The person lookup in subagent.md uses the handed-off account, which a Person id needs.
  • Adds a layout test holding the per-request steps within 14,000 characters (they end at 13,900, about 4,765 tokens), asserting they come in order, reading the handoff section alone to check it passes subagent.md and the read-it-first instruction, and asserting the '\'' escape in the acknowledgement and in subagent.md; it fails on main.
  • Fixes scripts/check-skill-drift.sh, which skipped frontmatter-less files whole; it now strips frontmatter only when present, checks subagent.md too, and two new drift-test fixtures cover frontmatter-less files.

Written for commit 479f4cd. Summary will update on new commits.

View guided diff Turn on auto-fix

After a compaction Claude Code re-attaches a skill cut to its first
5,000 tokens. basecamp-connect ran about 13,300 tokens, and the cut fell
before the handoff, so a compacted orchestrator could acknowledge a
request and lose the steps that dispatch it.

The skill now opens with what each request needs: starting and watching
the connector, the request line, and acknowledge, choose the repo, hand
off. The rules, invocation and first-time setup follow it, since they
matter only at start. The subagent's instructions move to subagent.md
beside SKILL.md, and the handoff passes its path for the subagent to
read itself, so the orchestrator no longer carries them or pastes them
into every dispatch. The subagent file inlines the boost loop it used to
reach "as above".

Measured by token usage through the API: the per-request part is 4,474
tokens (the rendered body, without frontmatter), the whole skill 9,353
(from 13,294), subagent.md 4,276. A test holds the per-request steps
within 14,000 characters of the body (about 4,800 tokens at this file's
2.9 characters a token) and checks the subagent file holds its steps;
both fail on main's skill.

The drift check stripped everything before a second "---", so it read
none of a file without frontmatter; it now strips frontmatter only when
the file opens with one, and checks subagent.md (12 commands, 23 flags),
shown red on a bogus command.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 20:46
@jeremy
jeremy requested a review from a team as a code owner October 12, 2026 20:46
@github-actions github-actions Bot added tests Tests (unit and e2e) skills Agent skills labels Oct 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T03:51:06.083837Z 479f4cd Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 6 files

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/connector/skill_layout_test.go Outdated

Copilot AI 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.

🟡 Changes recommended

The compacted and delegated paths contain shell-quoting and account-selection defects, with incomplete regression coverage.

4 open findings
What changed in this PR

Reorganizes the connector skill so essential request handling survives context compaction and delegates work through a standalone subagent guide.

Changes:

  • Moves per-request orchestration before the compaction cutoff.
  • Extracts subagent instructions into subagent.md.
  • Adds drift, layout, and packaging checks.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
skills/​basecamp-connect/​SKILL.md Reorders orchestration and references the subagent guide.
skills/​basecamp-connect/​subagent.md Adds standalone request-processing instructions.
scripts/​check-skill-drift.sh Handles files without frontmatter.
Makefile Checks the new guide for command drift.
internal/​release/​manifests_test.go Verifies the guide is shipped.
internal/​connector/​skill_layout_test.go Enforces compaction layout and extraction.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/connector/skill_layout_test.go Outdated
Comment thread scripts/check-skill-drift.sh
Comment thread skills/basecamp-connect/SKILL.md Outdated
Comment thread skills/basecamp-connect/subagent.md
…fixes

Copilot found the quoting rule now sits past the compaction cut while
the boost still interpolates the acknowledgement, so "I'm on it" would
break the command; and subagent.md never had the rule at all. Section a
and subagent.md now say how to quote a value, with that example. The
per-request part ends at 13,305 characters, inside the 14,000 budget.

cubic and Copilot found the handoff test could pass on the other
mention of subagent.md: it now reads section c alone and asserts the
instruction to read the file first, red with that line removed. Copilot
found the drift fix untested: two fixtures without frontmatter, one with
a later thematic break, both red against main's check-skill-drift.sh.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 20:53

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 4 files (changes from recent commits).

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/connector/skill_layout_test.go
Copilot AI previously approved these changes Oct 12, 2026

Copilot AI 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.

🟢 Approved

The restructuring is coherent and includes focused regression coverage for layout, drift validation, and packaging.

1 open finding
3 resolved since last review

🧠 Review effort: Balanced

@jeremy
jeremy requested a balanced review from Copilot October 12, 2026 21:00
@jeremy

jeremy commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

Copilot AI dismissed their stale review, a newer Copilot review was requested October 12, 2026 21:00
cubic found the test checked only the Shell quoting heading, so the
escape could go and the test still pass. It now asserts the '\'' escape
in the acknowledgement step and in subagent.md, red with the escape
removed from subagent.md.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: fdd8ec56b7

ℹ️ 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".

Copilot AI 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.

🟡 Changes recommended

The fallback requester lookup can target the wrong account when the requester name is absent.

1 open finding
4 resolved since last review

🧠 Review effort: Balanced

Comment thread skills/basecamp-connect/subagent.md Outdated
Copilot AI balanced review requested due to automatic review settings October 12, 2026 21:03

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 1 file (changes from recent commits).

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread internal/connector/skill_layout_test.go
Copilot AI previously approved these changes Oct 12, 2026

Copilot AI 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.

🟢 Approved

The implementation and regression coverage are sound; only a minor contributor-documentation mismatch remains.

1 open finding
Previously missed (1)

In code that hasn't changed since last review

Medium severity Update AGENTS.md to document the fourth drift-checked file

Makefile:490

This fourth drift input makes the contributor guidance stale: AGENTS.md:84-86 still says make check-skill-drift checks only the three SKILL.md files. Please include skills/basecamp-connect/subagent.md there so the documented CI contract matches this target.

🧠 Review effort: Balanced

@jeremy
jeremy requested a balanced review from Copilot October 12, 2026 21:21
@jeremy

jeremy commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

Copilot AI dismissed their stale review, a newer Copilot review was requested October 12, 2026 21:21

Copilot AI 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.

🟡 Changes recommended

The layout regression test does not currently enforce the required ordering of the per-request steps.

2 open findings

🧠 Review effort: Balanced

Comment thread internal/connector/skill_layout_test.go
Copilot AI balanced review requested due to automatic review settings October 12, 2026 21:52
Copilot AI dismissed their stale review, a newer Copilot review was requested October 12, 2026 21:52

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files (changes from recent commits).

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread skills/basecamp-connect/SKILL.md Outdated

Copilot AI 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.

🟡 Changes recommended

Retained post-compaction reply paths can write through the default human profile because their explicit agent-profile requirement moved beyond the cut.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread skills/basecamp-connect/SKILL.md
@jeremy
jeremy requested a balanced review from Copilot October 12, 2026 22:00
@jeremy

jeremy commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

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

Copy link
Copy Markdown

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: 387b3e5787

ℹ️ 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".

Comment thread skills/basecamp-connect/SKILL.md Outdated

Copilot AI 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.

🟡 Changes recommended

The extracted subagent behavior is not included in model-eval input or its CI path filter.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread skills/basecamp-connect/subagent.md
Copilot found the rule to post with --profile had moved past the cut
with the other rules, while the per-request part still posts a holding
reply and a refusal itself; it now says so before step a, and the
layout test asserts it. cubic found the full read before an owner's
connector change could delay the acknowledgement; it now comes after.

The per-request part ends at 13,900 characters, 4,765 tokens by API
usage, under the 5,000 kept after a compaction.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 22:05

Copilot AI 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.

🔵 Needs a closer look

The extracted subagent workflow is not exercised or triggered by the existing connector skill evals.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

@jeremy

jeremy commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Review threads: since the last summary, 7 more resolved (6 fixed, 1 declined), plus 2 left open for a decision.
Fixed from a review body:

One pattern, named so the next round doesn't keep growing it. Five findings in a row have been one class: something a compacted session might need sits past the 5,000-token cut (last.json, the restart after a setup change, setup itself, --profile, connector-exit recovery). The per-request part now holds what every request uses, at 4,765 tokens of 5,000. It can't also hold every rare path. The rare paths are covered by #887's SessionStart hook, which makes the session read the whole SKILL.md after every compaction, and by the one-line rule here to read it before an owner's connector change. I'd decline further findings of this class unless they name a step every request takes.

@jeremy
jeremy requested a balanced review from Copilot October 12, 2026 22:13
@jeremy

jeremy commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

Copilot AI 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.

🟡 Changes recommended

The owner-control reload lacks the fallback needed when ${CLAUDE_SKILL_DIR} remains literal, and extracted behavior remains outside model-eval coverage.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread skills/basecamp-connect/SKILL.md

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

Copy link
Copy Markdown

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: 59cba479e0

ℹ️ 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".

Comment thread skills/basecamp-connect/subagent.md
…s fallback

The per-request part tells the orchestrator to post a refusal and a holding
reply itself, before any subagent starts, but the reply commands now live
only in subagent.md, which it hands on without reading. It now points at
step 5 there. The owner-control reread used `${CLAUDE_SKILL_DIR}` with no
fallback for a client that leaves it literal; it now names the base
directory, as the handoff does.

The layout test pins both, and goes red on the previous text. The wording
around "as the agent" is shorter to stay inside the 14,000-character cut.
Copilot AI balanced review requested due to automatic review settings October 13, 2026 03:47
@jeremy

jeremy commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 479f4cd8a1

ℹ️ 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".

Copilot AI 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.

🟢 Approved

The restructure is coherent and backed by targeted layout, drift, and packaging checks.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

@jeremy
jeremy merged commit 839b558 into main Oct 13, 2026
32 checks passed
@jeremy
jeremy deleted the connect-skill-subagent-file branch October 13, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs skills Agent skills tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants