feat(harper-best-practices): add delegating-to-the-built-in-agent rule#68
feat(harper-best-practices): add delegating-to-the-built-in-agent rule#68kriszyp wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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`, |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| - **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 |
| 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 |
There was a problem hiding this comment.
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.
| 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`, |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| - **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 |
| 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 |
There was a problem hiding this comment.
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.
| 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>
2cccb1e to
49ba110
Compare
What
Adds a new
opsrule 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_promptoperations API +harper agentCLI landing in 5.2 via the harper#626 stack):agent:enabled + a generative backend; all agent ops are super_user.harper agentCLI (reusesharper logincreds, zero connector setup) and the raw operations API (agent_prompt→ pollget_agent_session→approve_agent_actiononawaiting_approval→ continue viasession_id)./mcpendpoint for MCP-native clients.Cross-links
deploying-to-harper-fabricso 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).ops, priority 4, order 7);SKILL.mdindex andAGENTS.mdregenerated deterministically from the manifest/bodies. Purely additive (0 deletions).npm run build,format:check,validate-skills, andvalidate-generatedall pass.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