Skip to content

feat: HITL SDK integration#50

Closed
AbirAbbas wants to merge 3 commits intomainfrom
feat/hitl
Closed

feat: HITL SDK integration#50
AbirAbbas wants to merge 3 commits intomainfrom
feat/hitl

Conversation

@AbirAbbas
Copy link
Copy Markdown
Collaborator

Summary

  • Add HITL (human-in-the-loop) integration with the AgentField SDK
  • Working POC for HITL workflow execution

Test plan

  • Verify HITL SDK integration works end-to-end
  • Test with running control plane

🤖 Generated with Claude Code

@AbirAbbas AbirAbbas marked this pull request as draft April 13, 2026 14:09
@AbirAbbas AbirAbbas marked this pull request as ready for review May 7, 2026 16:22
@AbirAbbas AbirAbbas closed this May 7, 2026
AbirAbbas added a commit that referenced this pull request May 7, 2026
* chore(deps): add hax-sdk + python-dotenv

Both unlock the HITL plan-approval gate landing in a follow-up commit:
hax-sdk is the human-approval client SWE-AF posts plans to, python-dotenv
lets containerised builds pick up HAX_API_KEY (and any future env-driven
config) from a mounted .env without baking it into the image.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(config): add plan-approval knobs to BuildConfig

max_plan_revision_iterations bounds the human "request changes" loop so a
reviewer can't accidentally pin a build forever; default 2 mirrors the
existing tech-lead review cap. approval_expires_in_hours is the wall-clock
ceiling on the hax-sdk request, default 72h so reviews can span a weekend
without the request expiring out from under the reviewer.

Both fields are inert until the HITL block in app.py reads them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(approval): pause builds for human plan review when HAX_API_KEY is set

Insert a checkpoint between Phase 1 (plan + git_init) and Phase 2 (execute):
when HAX_API_KEY is set in the environment, post the plan to hax-sdk via
plan-review-v2 and call agentfield's app.pause(), which transitions the
execution to "waiting" on the control plane and blocks until the reviewer
responds via webhook. No callback server in-process — the CP owns the
resume path, so the agent stays stateless and survives restarts.

On request_changes, re-run Architect → Tech Lead → Sprint Planner with the
reviewer's feedback (skipping PM since the PRD/scope is fixed) and re-post
for approval, bounded by cfg.max_plan_revision_iterations. On rejected /
expired / error, return a failure BuildResult without executing.

Approval requests are workspace-broadcast by default; setting
AGENTFIELD_APPROVAL_USER_ID assigns to a specific Hub user. State is
persisted to .artifacts/approval_state.json so a crashed-and-restarted
agent can be reasoned about.

Also wire load_dotenv() into both swe-planner and swe-fast entry points so
HAX_API_KEY (and other env-driven config) is available before Agent() is
constructed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(docker): use env_file in local compose so HITL env propagates

Replace the hand-listed ANTHROPIC_API_KEY / CLAUDE_CODE_OAUTH_TOKEN /
GH_TOKEN passthroughs with env_file: .env. The HITL gate adds HAX_API_KEY
(and optionally HAX_SDK_URL, AGENTFIELD_APPROVAL_USER_ID), and growing the
hand-listed array every time a new env var is needed loses to just letting
docker-compose load the whole .env.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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