Skip to content

[Story] Resume FullSend agents from GitHub comment answers #513

Description

@beatrizmcouto

👤 User Story

As a
contributor working with a headless uf agent

I want to
phase-gate questions posted as GitHub comments and answered with /uf.answer, with a committed resume brief

So that
AskUserQuestion does not block sandbox runs and work can continue from a checkpoint

🎯 Acceptance Criteria

  • At spec-driven phase gates only (never mid-reasoning), agent may emit status: needs_input + pending_question
  • A resume brief is committed on the working branch as state.json (phase, decisions, pending decision, next action)
  • post_script posts the question as a GitHub comment
  • /uf.answer <text> re-triggers the harness; pre_script feeds the answer + resume brief back in
  • Cold resume from the checkpoint is the default path
  • uf-address-feedback is the first harness that uses this loop
  • Existing Inc1 schema fields pending_question / needs_input are used — no schema break

🚫 Out of Scope

  • Write-capable specify/code agents

Dependencies

  • Increment 1 uf-review harness + result schema (#512)
  • OpenCodeRuntime interim transcript support (#510)

Increment 2. Clear loop, comments-only (security-hook gap still acceptable). Comparable to other M multi-component glue stories.

🏁 Definition of Done — 🛠️ Quality & Testing

  • Code has been peer-reviewed for bugs and vulnerabilities.
  • Proper testing has been completed and passes (Unit, Integration, E2E via GitHub Actions).
  • The feature has been demonstrated/validated successfully in the target environment.

🏁 Definition of Done — 📝 Architecture & Docs

  • Usage documentation or changelog updated (if user-facing changes introduced).
  • Local ADR written and verified by Tech Lead if technical architecture deviated.
  • Any newly introduced technical debt has been logged as a GitHub issue.

Context


Implementation Notes (added by @jflowers, Aug 2026)

Cold resume mechanism (default for Inc2):

At spec phase gates ONLY (never mid-reasoning), the agent emits status: needs_input + pending_question in the result JSON. The resume brief is committed on the working branch as state.json:

{
  "phase": "specify",
  "decisions": ["decision-1-text", "decision-2-text"],
  "pending_decision": "What authentication provider should we use?",
  "next_action": "Resume specify phase after answer"
}

Flow:

  1. Agent hits a phase gate requiring input → emits status: needs_input + pending_question
  2. post_script (post-uf-review.sh or equivalent) posts the question as a GitHub comment
  3. User replies with /uf.answer <text> → re-triggers the harness via CEL trigger
  4. pre_script reads the answer from the comment + loads state.json from the branch → feeds both to the agent
  5. Agent resumes from state.json context (cold resume — new session, not warm continuation)

Warm resume deferred: OpenCode --session/--continue + opencode.db export/import is a separate spike, NOT a dependency for Inc2. Cold resume is sufficient.

Schema reuse: uses the same uf-review-result.schema.json fields from Inc1 — status, pending_question are already in the schema (no breaking changes).

First harness: uf-address-feedback — the first agent to use the async Q&A flow.


Question-tool override design (added by @jflowers, Aug 2026)

Problem: The /opsx-propose → /uf.unleash pipeline — and skills like openspec-propose, openspec-apply-change, speckit.specify, speckit.implement — all call the built-in question tool for interactive input. Locally this renders a TUI picker; headless opencode run in FullSend has no interactive user to prompt.

Solution: Override the built-in question tool with a custom implementation that serializes questions to a file and signals halt, keeping all committed commands/skills unchanged.

Mechanism (verified): OpenCode custom tools docs state: "If a custom tool uses the same name as a built-in tool, the custom tool takes precedence." Custom tools in ~/.config/opencode/tools/ load globally.

Injection: Ship question.ts as a uf .fullsend host_file, uploaded to ~/.config/opencode/tools/question.ts inside the sandbox during bootstrap. This activates the override only in FullSend — local development retains the interactive built-in. The file is NOT placed in the repo's .opencode/tools/ (which would override locally too).

Flow (terminate-and-resume only — no block-and-poll):

1. Agent calls `question` tool (same API: header, question, options[])
2. Custom question.ts:
   a. Writes pending_questions.json to /sandbox/workspace/output/
   b. Returns halt sentinel instructing agent to stop and emit needs_input
3. Agent sets status:needs_input + pending_question in output
4. Run ends → host reads output, finds pending_questions.json
5. post_script posts numbered GH comment:
   "## /uf.unleash paused: question
    Q1: [header] — [question]
    Options: A) … B) … C) Custom
    Reply with: /uf.answer Q1: A, Q2: Custom - [details]"
6. Human replies /uf.answer Q1: A, Q2: details
7. FullSend re-triggers → pre_script feeds answer + state.json
8. Agent resumes (cold) with answers injected

Answer format: Reuses the "Q1: A, Q2: Custom - [details]" batch format already taught in speckit.specify.md:234-235.

Reliability backstops:

  • Command-level instruction: "If the question tool returns a halt sentinel, you MUST stop immediately."
  • Host validate script: if pending_questions.json exists but output status ≠ needs_input, fail + re-run (bounded by validation_loop.max_retries).

Phase 0 dependency (#509, spike task 7): Confirm (a) what the built-in question tool does under opencode run headless (error vs. hang vs. no-op), and (b) that a global custom question.ts overrides it in headless mode.

Harness wiring (Inc2+): Add to harness host_files:

host_files:
  - src: .fullsend/tools/question.ts
    dest: /home/sandbox/.config/opencode/tools/question.ts
    optional: true   # Inc1 (read-only) does not need the override

Trace fidelity & TranscriptHandler redesign (spun out from #510)

#510 ships an interim transcript approach: tee opencode run --format json stdout to output.jsonl and parse it with the existing file-based TranscriptHandler interface. This is sufficient for error annotation and basic debugging but insufficient for session resumption (which this story needs) and full retro analysis (ADR 0021).

Background: fullsend#1935 proposed redesigning TranscriptHandler to be format-neutral (not file-based), but was closed as completed (2026-08-12, by @waynesun09) without the redesign landing in code — transcript.go still has the file-based interface. The unbound-force team's design question (em-redhat's comment) — (a) reuse existing AgentEvent sequence for post-run trace access, or (b) define a richer TraceRecord type (full tool I/O, timestamps, session IDs) — was not answered before closure.

What this story must resolve:

  1. IR design decision: confirm with fullsend maintainers (@sonupreetam / @maruiz93 / @waynesun09 on fullsend#1260) whether AgentEvent reuse is sufficient or a richer trace format is needed. This determines the shape of the cold-resume state.json and whether it can carry forward enough context for warm resume later.

  2. Full-fidelity extraction path: OpenCode stores sessions in SQLite and provides opencode export <sessionID> for full-fidelity dumps (user messages, system context, compaction events — things the NDJSON stream lacks). Evaluate whether cold resume needs this richer data or if state.json + output.jsonl is enough.

  3. Warm resume spike (not blocking this story): OpenCode --session/--continue + opencode.db export/import. If cold resume proves sufficient for Inc2, warm resume becomes a follow-up spike. If not, it may need to land here.

Related upstream issues:

  • fullsend#1935 — TranscriptHandler redesign (closed, no code landed)
  • fullsend#1260 — OpenCode runtime tracking epic (open)
  • #510 — OpenCodeRuntime contribution (ships interim tee, defers trace redesign here)

Clarification: schema fields + input sanitization (added Aug 2026, per review feedback)

pending_question / needs_input are net-new fields. They do not exist in any current schema under schemas/. The uf-review-result schema itself is a net-new deliverable of #512 (Inc1). This story (#513) reuses those schema fields — it does not create them. The fields status, pending_question, and provenance will be defined in #512's schema delivery.

/uf.answer input sanitization (security requirement): The /uf.answer <text> trigger feeds untrusted GitHub comment content into the agent execution context. This is a significant injection surface. The pre_script that processes /uf.answer MUST:

  1. Length cap — reject answers exceeding a reasonable limit (e.g., 4000 chars)
  2. Control-character stripping — remove ANSI escape sequences, null bytes, and non-printable characters
  3. Data treatment — pass the answer as a data file read by the agent, never interpolated into shell commands or prompt templates
  4. Shape validation — if the pending question expects a structured answer (e.g., yes/no, option selection), validate the answer matches the expected shape before passing it through
  5. Audit trail — log the raw answer content (truncated) in the pre_script output for post-incident review

Activity

  1. added
    enhancement
    llm_assisted
    on Aug 17, 2026
  2. added this to the FullSend BYOA milestone on Aug 18, 2026
  3. jflowers commented on Aug 24, 2026

    @jflowers
    Contributor

    Pin extraction to opencode export, down-weight fullsend-ai/fullsend#1935 dependency

    pi shipped its own transcript handling (session JSONL) while fullsend-ai/fullsend#1935 is still open — so #1935 is not a hard blocker for a second runtime. Reframe it as "informs this story," not "blocks."

    Hard requirement for resumption: use opencode export <sessionID> (full session JSON, supports --sanitize) — not the opencode run --format json ndjson stream, which lacks user messages / system context / compaction events and is insufficient for resume + retro (ADR 0021's three trace consumers). parseOpenCodeStream already captures the sessionID needed to call export.

  4. jflowers commented on Aug 24, 2026

    @jflowers
    Contributor

    Correction: plugin-registered question tool may override the built-in block

    Follow-up to the plan refresh comment and #509 Spike 7.

    The Spike 7 finding

    Spike 7 found that a custom tool named question (.opencode/tools/question.ts) is silently blocked by the headless mode permission deny rule {permission: "question", action: "deny"}. The workaround was to name it ask instead.

    The correction

    From opencode.ai/docs/plugins:

    "If a plugin tool uses the same name as a built-in tool, the plugin tool takes precedence."

    This means a plugin-registered tool named question (.opencode/plugins/question-override.ts) should override the built-in, potentially bypassing the permission block that affects bare custom tools. The question-answer bridge for Inc2 should be implemented as a plugin tool, not a custom tool.

    Why this matters for #513

    The Inc2 design needs an async question→GitHub-comment→answer flow. If the plugin override works:

    1. Register a question tool via a plugin that posts to GitHub and returns a placeholder
    2. The built-in question permission deny becomes irrelevant (plugin takes precedence)
    3. No need to rename to ask — the tool name matches what the model naturally calls

    This needs validation (the precedence rule may not override permission denials — it could be that the permission system runs before tool dispatch). But it's worth testing before committing to the ask rename, since using the canonical question name reduces the chance of the model not calling it when it should.

    Related: shell.env for .env.d sourcing

    The plugin system also exposes a shell.env hook that injects environment variables into all shell execution. This could replace the explicit .env.d sourcing the harness currently needs (Spike 3 finding), making the entrypoint cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementllm_assisted

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions