For new pipelines (resume_mode is absent):
a. If result.fetch_needed is non-null:
- Fetch the external data using the method specified in
fetch_needed:
- If
fetch_needed.mcp_tool is set: call the MCP tool with fetch_needed.mcp_params.
- Else if
fetch_needed.command is set: execute the command via Bash and parse the JSON output.
- Else: follow
fetch_needed.instruction as a fallback guide.
- Map the response fields to
external_context using fetch_needed.response_mapping:
for each entry (response_key → context_key), set external_context[context_key] = response[response_key].
- Call
mcp__forge-state__pipeline_init_with_context(workspace=result.workspace, source_id=result.source_id, source_url=result.source_url, flags=result.flags, external_context=<mapped data>).
(task_text is not applicable for external issue sources — do not pass it.)
b. If result.fetch_needed is null (plain text input): call
mcp__forge-state__pipeline_init_with_context(workspace=result.workspace, flags=result.flags, task_text=result.core_text).
(result.core_text is a top-level field in the pipeline_init response — the task text with bare flags stripped.)
After the first pipeline_init_with_context call, check which field is present in the response:
If result.needs_discussion is non-null (triggered only when --discuss flag is present,
source is plain text, and --auto is absent):
- Present each question in
result.needs_discussion.questions to the user via AskUserQuestion
(single prompt listing all questions).
- Collect the user's answers as a single freeform string
(e.g.
"Q1: <answer>\nQ2: <answer>\nQ3: <answer>").
- Call
mcp__forge-state__pipeline_init_with_context again (the discussion call) with:
workspace=<same>, flags=<same>, task_text=<same>, discussion_answers=<collected answers string>.
The response will contain needs_user_confirmation where
needs_user_confirmation.enriched_request_body is non-empty.
- Proceed with the effort/branch confirmation step below using this
needs_user_confirmation.
When calling pipeline_init_with_context with user_confirmation, pass back:
user_confirmation={effort: <confirmed>, workspace_slug: <slug>, use_current_branch: <bool>, enriched_request_body: needs_user_confirmation.enriched_request_body}.
This carries the enriched request.md body forward to workspace initialisation.
If result.needs_user_confirmation is present directly (--discuss absent, --auto set,
or GitHub/Jira source): proceed with the effort/branch confirmation step below
(no enriched_request_body to pass back).
Effort/branch confirmation step (applies after either path above):
Present all of the following to the user in a single prompt (use AskUserQuestion
with multiple questions):
- Effort level: present all three effort options from
effort_options
(S, M, L — each with skipped_phases using the label field).
Each option has a recommended boolean — mark the one where
recommended is true as "(Recommended)".
If needs_user_confirmation.estimate_display is non-empty, output it verbatim
alongside the options so the user can gauge how heavy the run will be (effort L can
be multi-hour and multi-dollar). The server pre-formats the P50/P90 figures — do not
reconstruct them from the raw estimate struct.
- Branch decision: based on
current_branch and is_main_branch from the response:
- If
is_main_branch is true: inform the user a new branch will be created (no question needed).
- If
is_main_branch is false: ask whether to use the current branch or create a new one.
While waiting, generate a concise English slug (3–6 words, lowercase, hyphen-separated,
ASCII only) that summarises the task — e.g. "add-user-auth-endpoint" or
"fix-report-export-timeout". If the input is in a non-English language, translate
the core intent into English for the slug.
Do not include the issue number (GitHub #N or Jira PROJ-123) in the slug —
the server prepends source_id automatically when present.
Then call mcp__forge-state__pipeline_init_with_context again with the same parameters plus
user_confirmation={effort: <confirmed>, workspace_slug: <slug>, use_current_branch: <bool>}.
If needs_user_confirmation.enriched_request_body is non-empty (from the discussion path),
also include enriched_request_body: <value> inside user_confirmation.
The response will contain branch (the branch name) and create_branch (boolean).
If create_branch is true: run git checkout -b <branch> via Bash immediately.
Use the workspace from the confirmed response for all subsequent calls.
Important: Always pass the workspace path from pipeline_init unchanged to the first
pipeline_init_with_context call. Never construct workspace paths manually.