Skip to content

feat(harper-best-practices): add delegating-to-the-built-in-agent rule#68

Draft
kriszyp wants to merge 1 commit into
mainfrom
kris/agent-delegation-skill
Draft

feat(harper-best-practices): add delegating-to-the-built-in-agent rule#68
kriszyp wants to merge 1 commit into
mainfrom
kris/agent-delegation-skill

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 3, 2026

Copy link
Copy Markdown
Member

What

Adds a new ops rule to the harper-best-practices skill: delegating-to-the-built-in-agent.

It teaches a client agent the lifecycle for handing work to Harper's built-in agent (the agent_prompt operations API + harper agent CLI landing in 5.2 via the harper#626 stack):

  • When to delegate — server-side work best done in-process (schema/component changes, restart, worker debug/profile via the inspector, larger multi-step handoffs).
  • Prerequisitesagent: enabled + a generative backend; all agent ops are super_user.
  • Two drive paths — the harper agent CLI (reuses harper login creds, zero connector setup) and the raw operations API (agent_prompt → poll get_agent_sessionapprove_agent_action on awaiting_approval → continue via session_id).
  • MCP alternative — curated agent tools at the ops API /mcp endpoint for MCP-native clients.

Cross-links deploying-to-harper-fabric so the deploy → connect → delegate flow reads as one lifecycle.

Why

Closes the UX gap where the skills path taught building + deploying an app but had no knowledge of the built-in agent it could delegate to. This makes the skills route a first-class, low-friction way to reach the agent (piggybacks on the deploy credential chain) alongside MCP.

Mechanics

  • mode: synthesized (hand-authored — no upstream doc source exists for #626 yet).
  • Manifest entry added (ops, priority 4, order 7); SKILL.md index and AGENTS.md regenerated deterministically from the manifest/bodies. Purely additive (0 deletions).
  • npm run build, format:check, validate-skills, and validate-generated all pass.

⚠️ Merge / release timing

Draft — the ops this rule documents ship with the harper#626 stack in 5.2. Do not merge/release before that stack lands, or the skill will reference operations that don't exist yet. Target: release just ahead of the 5.2 cut.

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds comprehensive documentation and best practices for delegating tasks to Harper's built-in agent (introduced in Harper 5.2+), updating AGENTS.md, SKILL.md, rules.manifest.yaml, and creating a new rule file delegating-to-the-built-in-agent.md. The review feedback suggests formatting improvements to ensure proper YAML spacing (e.g., autoApprove: false instead of autoApprove:false) in the inline examples, and recommends enhancing the programmatic polling loop example to capture and print the final session status rather than exiting silently.

Poll until `status` leaves `running` — terminal states are `completed`, `aborted`, and `error`;
`awaiting_approval` means it is paused for an approval decision (see step 3).

3. **Approve or deny a paused action.** When the agent enabled configuration has `autoApprove:false`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In YAML, keys and values should be separated by a space after the colon (e.g., autoApprove: false instead of autoApprove:false). This ensures standard YAML formatting and prevents potential parsing issues if users copy-paste this configuration.

Suggested change
3. **Approve or deny a paused action.** When the agent enabled configuration has `autoApprove:false`,
3. **Approve or deny a paused action.** When the agent enabled configuration has `autoApprove: false`,


- **All agent operations require super_user.** Prefer a stored `harper login` token or a JWT over
passing credentials inline, and avoid embedding long-lived credentials in scripts.
- **Approvals are your safety gate.** With `autoApprove:false`, the agent pauses before destructive

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In YAML, keys and values should be separated by a space after the colon (e.g., autoApprove: false instead of autoApprove:false). This ensures standard YAML formatting and prevents potential parsing issues if users copy-paste this configuration.

Suggested change
- **Approvals are your safety gate.** With `autoApprove:false`, the agent pauses before destructive
- **Approvals are your safety gate.** With `autoApprove: false`, the agent pauses before destructive

Comment on lines +123 to +126
while [ "$(curl -s -u <user>:<pass> <ops-endpoint> -H 'Content-Type: application/json' \
-d "{\"operation\":\"get_agent_session\",\"session_id\":\"$SID\"}" | jq -r .status)" = "running" ]; do
sleep 3
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current programmatic polling loop exits as soon as the status is no longer "running". However, if the session transitions to awaiting_approval, the loop terminates silently without indicating the final status or prompting the user. Capturing the final status in a variable and printing it after the loop exits provides better visibility and debugging information.

Suggested change
while [ "$(curl -s -u <user>:<pass> <ops-endpoint> -H 'Content-Type: application/json' \
-d "{\"operation\":\"get_agent_session\",\"session_id\":\"$SID\"}" | jq -r .status)" = "running" ]; do
sleep 3
done
while true; do
STATUS=$(curl -s -u <user>:<pass> <ops-endpoint> -H 'Content-Type: application/json' \
-d "{\"operation\":\"get_agent_session\",\"session_id\":\"$SID\"}" | jq -r .status)
if [ "$STATUS" != "running" ]; then
break
fi
sleep 3
done
echo "Session ended with status: $STATUS"

Poll until `status` leaves `running` — terminal states are `completed`, `aborted`, and `error`;
`awaiting_approval` means it is paused for an approval decision (see step 3).

3. **Approve or deny a paused action.** When the agent enabled configuration has `autoApprove:false`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In YAML, keys and values should be separated by a space after the colon (e.g., autoApprove: false instead of autoApprove:false). This ensures standard YAML formatting and prevents potential parsing issues if users copy-paste this configuration.

Suggested change
3. **Approve or deny a paused action.** When the agent enabled configuration has `autoApprove:false`,
3. **Approve or deny a paused action.** When the agent enabled configuration has `autoApprove: false`,


- **All agent operations require super_user.** Prefer a stored `harper login` token or a JWT over
passing credentials inline, and avoid embedding long-lived credentials in scripts.
- **Approvals are your safety gate.** With `autoApprove:false`, the agent pauses before destructive

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In YAML, keys and values should be separated by a space after the colon (e.g., autoApprove: false instead of autoApprove:false). This ensures standard YAML formatting and prevents potential parsing issues if users copy-paste this configuration.

Suggested change
- **Approvals are your safety gate.** With `autoApprove:false`, the agent pauses before destructive
- **Approvals are your safety gate.** With `autoApprove: false`, the agent pauses before destructive

Comment on lines +2645 to +2648
while [ "$(curl -s -u <user>:<pass> <ops-endpoint> -H 'Content-Type: application/json' \
-d "{\"operation\":\"get_agent_session\",\"session_id\":\"$SID\"}" | jq -r .status)" = "running" ]; do
sleep 3
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current programmatic polling loop exits as soon as the status is no longer "running". However, if the session transitions to awaiting_approval, the loop terminates silently without indicating the final status or prompting the user. Capturing the final status in a variable and printing it after the loop exits provides better visibility and debugging information.

Suggested change
while [ "$(curl -s -u <user>:<pass> <ops-endpoint> -H 'Content-Type: application/json' \
-d "{\"operation\":\"get_agent_session\",\"session_id\":\"$SID\"}" | jq -r .status)" = "running" ]; do
sleep 3
done
while true; do
STATUS=$(curl -s -u <user>:<pass> <ops-endpoint> -H 'Content-Type: application/json' \
-d "{\"operation\":\"get_agent_session\",\"session_id\":\"$SID\"}" | jq -r .status)
if [ "$STATUS" != "running" ]; then
break
fi
sleep 3
done
echo "Session ended with status: $STATUS"

Documents the lifecycle for delegating work to Harper's built-in agent
(harper#626, shipping in 5.2): prerequisites, the `harper agent` CLI, the
agent operations API (agent_prompt → get_agent_session → approve_agent_action),
and the MCP transport alternative. Reuses the deploy/login credential chain so
no separate connector setup is needed.

Synthesized rule (no upstream doc source yet); manifest + regenerated SKILL.md
index and AGENTS.md updated accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kriszyp kriszyp force-pushed the kris/agent-delegation-skill branch from 2cccb1e to 49ba110 Compare July 4, 2026 04:12
@kriszyp kriszyp requested review from dawsontoth and heskew July 4, 2026 11:41
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.

2 participants