-
Notifications
You must be signed in to change notification settings - Fork 15
feat: add generic refine agent #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e31798d
f76da55
3249287
ca1e31d
7f1ed0e
a35e371
b3646f0
2011881
2ed4e6e
7d9d755
2072453
5f73801
bee87be
84b2b45
d4bdc62
e52b424
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Refine Agent | ||
|
|
||
| Decomposes a work item — feature, epic, story, or issue — into implementable child work items with testable acceptance criteria, dependency analysis, and confidence scoring. Always produces a plan, even when information is incomplete. | ||
|
|
||
| ## How the agent works | ||
|
|
||
| The refine agent runs after the explore agent has gathered technical context. It reads the issue description, exploration context (codebase analysis, related work, competitive landscape), and any prior critique feedback. It then decomposes the work item into a hierarchy of child issues sized for engineering teams and sprints. | ||
|
|
||
| The agent runs in a read-only sandbox. It cannot modify issues, push code, or create child issues. Its only output is a structured JSON refinement plan consumed by the post-script, which posts a summary comment, attaches the plan to the issue, updates the issue description when the agent proposes a revised one, and adds a `ready-to-critique` label to signal the [critique agent](critique.md). | ||
|
|
||
| ## How it helps | ||
|
|
||
| - Features get decomposed into actionable work items within minutes instead of waiting for a refinement meeting. | ||
| - Vague requirements are flagged as open questions with explicit assumptions, preventing silent scope gaps. | ||
| - Cross-cutting dependencies are identified early, before teams start implementation in silos. | ||
| - Each child issue includes testable acceptance criteria, making "done" unambiguous. | ||
|
|
||
| ## Commands | ||
|
|
||
| | Command | Where | Effect | | ||
| |---------|-------|--------| | ||
| | `/fs-refine` | Issue comment | Runs refinement on the issue | | ||
|
|
||
| The `/fs-refine` command accepts an optional human directive after the command (e.g., `/fs-refine focus on the API layer first`) that guides the agent's decomposition priorities. | ||
|
|
||
| ## Pipeline integration | ||
|
|
||
| The refine agent is part of a three-stage refinement pipeline: | ||
|
|
||
| 1. **Explore** — gathers technical context from the codebase, GitHub, Jira, and web | ||
| 2. **Refine** — decomposes the work item into implementable children (this agent) | ||
| 3. **Critique** — reviews the decomposition and approves, requests revisions, or escalates | ||
|
|
||
| > **Note**: The explore and critique agents are added in separate PRs. Cross-references to their docs pages will resolve once all three PRs merge. | ||
|
|
||
| Agents communicate through issue labels and attachments. No direct workflow chaining. | ||
|
|
||
| ### Revision rounds | ||
|
|
||
| When the critique agent requests revisions, the refine agent re-runs with the critique feedback. Each round addresses specific revision requests (remove, merge, split, revise, add). The pipeline iterates up to `MAX_REVIEW_ROUNDS` (default: 3) before escalating to a human. | ||
|
|
||
| ## Control labels | ||
|
|
||
| These labels are managed by the refinement pipeline: | ||
|
|
||
| | Label | Meaning | | ||
| |-------|---------| | ||
| | `ready-to-critique` | Refine posted a plan; critique agent should review it | | ||
| | `ready-to-refine` | Critique requested revisions; refine should re-run | | ||
| | `refine-revision-round-N` | Tracks which revision round the pipeline is on | | ||
| | `refine-approved` | Critique approved the plan; ready for human review or auto-creation | | ||
| | `refine-needs-input` | Critique determined a human must answer a question before proceeding | | ||
| | `refine-needs-human` | Max review rounds reached; human decision needed | | ||
|
|
||
| ## Platform support | ||
|
|
||
| The refine agent supports work items from multiple platforms: | ||
|
|
||
| - **GitHub Issues** — uses labels and sub-issues for hierarchy | ||
| - **Jira** — uses typed issue hierarchy (Feature → Epic → Story → Task) | ||
| - **GitLab** — uses epics, issues, and labels (planned) | ||
|
|
||
| Platform-specific hierarchy rules and description formats are injected via `PLATFORM_CONTEXT`. | ||
|
|
||
| ## Configuration and extension | ||
|
|
||
| ### Routing skill | ||
|
|
||
| To route child issues to different Jira projects based on team ownership, provide a routing skill at `.fullsend/skills/jira-routing/SKILL.md` or `.agents/skills/project-routing/SKILL.md`. The routing skill maps team ownership domains to projects so child issues are created in the right project. Without a routing skill, all children are created in the parent issue's project. | ||
|
|
||
| ### Platform context | ||
|
|
||
| Platform context files (`platform-jira.md`, `platform-github.md`, `platform-gitlab.md`) are **thin**: links to official forge docs, plus the Fullsend refine/create contract (`type`, `parent_title`, optional `target_project`). Org process belongs in `ORG_KNOWLEDGE` / `PROJECT_ROUTING`, not these files. The pre-script selects one based on `ISSUE_SOURCE`. | ||
|
|
||
| ## Source | ||
|
|
||
| [`harness/refine.yaml`](../harness/refine.yaml) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export ISSUE_CONTEXT=/sandbox/workspace/issue-context.json | ||
| export EXPLORE_CONTEXT=/sandbox/workspace/exploration_context.json | ||
| export CRITIQUE_FEEDBACK=/sandbox/workspace/critique-feedback.json | ||
| export REVIEW_ROUND=${REVIEW_ROUND:-1} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] naming-inconsistency Uses ${REVIEW_ROUND:-1} shell parameter expansion while other env files use plain static exports. Suggested fix: Use a plain static export (export REVIEW_ROUND=1). |
||
| export PROJECT_ROUTING=/sandbox/workspace/routing-skill.md | ||
| export PLATFORM_CONTEXT=/sandbox/workspace/platform-context.md | ||
| export ORG_KNOWLEDGE=/sandbox/workspace/org-knowledge.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| --- | ||
| agent: agents/refine.md | ||
| doc: docs/refine.md | ||
| model: opus | ||
| image: ghcr.io/fullsend-ai/fullsend-sandbox:latest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [medium] image-not-pinned All existing harness definitions pin the sandbox image by digest (@sha256:...). The refine harness uses :latest, which is non-reproducible and breaks the codebase convention for deterministic builds. Suggested fix: Pin the image to a specific sha256 digest matching the pattern in other harness files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [medium] image-not-pinned All existing harness definitions pin the sandbox image by digest (@sha256:...). The refine harness uses :latest, which is non-reproducible and breaks the codebase convention for deterministic builds. Suggested fix: Pin the image to a specific sha256 digest. |
||
| policy: policies/refine.yaml | ||
|
|
||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
| role: refine | ||
| slug: fullsend-ai-refine | ||
|
|
||
| host_files: | ||
| - src: common/env/gcp-vertex.env | ||
| dest: /sandbox/workspace/.env.d/gcp-vertex.env | ||
| expand: true | ||
| - src: env/refine.env | ||
| dest: /sandbox/workspace/.env.d/refine.env | ||
| expand: true | ||
| - src: ${GOOGLE_APPLICATION_CREDENTIALS} | ||
| dest: /tmp/.gcp-credentials.json | ||
| - src: ${GCP_OIDC_TOKEN_FILE} | ||
| dest: /sandbox/workspace/.gcp-oidc-token | ||
| optional: true | ||
|
|
||
| pre_script: scripts/pre-refine.sh | ||
| post_script: scripts/post-refine.sh | ||
|
|
||
| validation_loop: | ||
| script: scripts/validate-output-schema.sh | ||
| schema: schemas/refine-result.schema.json | ||
| max_iterations: 2 | ||
|
|
||
| timeout_minutes: 25 | ||
|
|
||
| env: | ||
| runner: | ||
| ISSUE_KEY: "${ISSUE_KEY}" | ||
| ISSUE_SOURCE: "${ISSUE_SOURCE}" | ||
| REPO_FULL_NAME: "${REPO_FULL_NAME}" | ||
| EXPLORE_RUN_ID: "${EXPLORE_RUN_ID}" | ||
| EXPLORE_CONTEXT_REF: "${EXPLORE_CONTEXT_REF}" | ||
| CRITIQUE_RUN_ID: "${CRITIQUE_RUN_ID}" | ||
| REVIEW_ROUND: "${REVIEW_ROUND}" | ||
| MAX_REVIEW_ROUNDS: "${MAX_REVIEW_ROUNDS}" | ||
| AUTO_CREATE: "${AUTO_CREATE}" | ||
| GITHUB_ISSUE_NUMBER: "${GITHUB_ISSUE_NUMBER}" | ||
| HUMAN_DIRECTIVE: "${HUMAN_DIRECTIVE}" | ||
| sandbox: | ||
|
qodo-code-review[bot] marked this conversation as resolved.
|
||
| REVIEW_ROUND: "${REVIEW_ROUND}" | ||
| HUMAN_DIRECTIVE_FILE: "/sandbox/workspace/human-directive.txt" | ||
|
|
||
| forge: | ||
| github: | ||
| pre_script: scripts/pre-refine.sh | ||
| post_script: scripts/post-refine.sh | ||
| env: | ||
| runner: | ||
| GH_TOKEN: "${GH_TOKEN}" | ||
| PUSH_TOKEN: "${PUSH_TOKEN}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] excessive-permission PUSH_TOKEN injected into runner environment but never referenced in post-refine.sh script body. Violates least-privilege. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] excessive-permission PUSH_TOKEN injected into runner environment but never referenced in post-refine.sh script body. Violates least-privilege. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --- | ||
| version: 1 | ||
|
|
||
| # Sandbox policy for the refine agent. | ||
| # | ||
| # Read-only agent: needs GitHub API for issue context and Jira for | ||
| # attachment retrieval. No write access to either — the post-script | ||
| # handles mutations on the runner. | ||
|
|
||
| filesystem_policy: | ||
| include_workdir: true | ||
| read_only: [/usr, /lib, /proc, /dev/urandom, /app, /etc, /var/log] | ||
| read_write: [/sandbox, /tmp, /dev/null] | ||
| landlock: | ||
| compatibility: best_effort | ||
| process: | ||
| run_as_user: sandbox | ||
| run_as_group: sandbox | ||
|
|
||
| network_policies: | ||
| vertex_ai: | ||
| name: vertex-ai | ||
| endpoints: | ||
| - host: "api.anthropic.com" | ||
| port: 443 | ||
| protocol: rest | ||
| enforcement: enforce | ||
| access: read-write | ||
| - host: "*.googleapis.com" | ||
| port: 443 | ||
| protocol: rest | ||
| enforcement: enforce | ||
| access: read-write | ||
| binaries: | ||
| - path: "**/claude" | ||
| - path: "**/node" | ||
|
|
||
| github_api: | ||
| name: github-api | ||
| endpoints: | ||
| - host: "api.github.com" | ||
| port: 443 | ||
| protocol: rest | ||
| enforcement: enforce | ||
| access: read-only | ||
| - host: "github.com" | ||
| port: 443 | ||
| protocol: rest | ||
| enforcement: enforce | ||
| access: read-only | ||
| - host: "raw.githubusercontent.com" | ||
| port: 443 | ||
| protocol: rest | ||
| enforcement: enforce | ||
| access: read-only | ||
| binaries: | ||
| - path: "**/gh" | ||
| - path: "**/git" | ||
| - path: "**/node" | ||
|
|
||
| jira_api: | ||
| name: jira-api | ||
| endpoints: | ||
| - host: "*.atlassian.net" | ||
| port: 443 | ||
| protocol: rest | ||
| enforcement: enforce | ||
| access: read-only | ||
| binaries: | ||
| - path: "**/curl" | ||
| - path: "**/node" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same deal as the other PR, move this to the harness