From 2165590fadbd6a539fba224716a1c43b6ac8dddf Mon Sep 17 00:00:00 2001 From: apetruni Date: Thu, 22 Oct 2026 13:47:24 +0300 Subject: [PATCH] fix(#8648): use work item URL in generated agents Signed-off-by: apetruni --- docs/cli/agent.md | 2 +- internal/agentnew/render.go | 4 ++-- internal/agentnew/render_test.go | 22 +++++++++++++++++++ internal/agentnew/templates/post.sh.tmpl | 2 +- internal/agentnew/testdata/golden/codex.txt | 6 ++--- .../agentnew/testdata/golden/pi-openai.txt | 6 ++--- internal/agentnew/testdata/golden/triage.txt | 6 ++--- .../testdata/golden/validation-loop.txt | 6 ++--- internal/cli/agent_new.go | 2 +- internal/harness/checkgenerated.go | 2 +- 10 files changed, 40 insertions(+), 18 deletions(-) diff --git a/docs/cli/agent.md b/docs/cli/agent.md index d278d8dc8d..522ee8e363 100644 --- a/docs/cli/agent.md +++ b/docs/cli/agent.md @@ -50,7 +50,7 @@ Next: 2. Test locally, printing the result instead of commenting: POST_LINT_DOCS_DRY_RUN=1 fullsend run lint-docs \ --target-repo . --env-file .env.local - .env.local needs GITHUB_ISSUE_URL, ISSUE_NUMBER, REPO_FULL_NAME, + .env.local needs FULLSEND_WORK_ITEM_URL, ISSUE_NUMBER, REPO_FULL_NAME, GH_TOKEN, ANTHROPIC_VERTEX_PROJECT_ID, CLOUD_ML_REGION, and GOOGLE_APPLICATION_CREDENTIALS pointing at a GCP credentials file; the run stops before it starts without them. diff --git a/internal/agentnew/render.go b/internal/agentnew/render.go index 51fa37fafe..2f565b2c7b 100644 --- a/internal/agentnew/render.go +++ b/internal/agentnew/render.go @@ -100,7 +100,7 @@ func buildHarness(opts Options, role Role) (*harness.Harness, error) { // gives gh a placeholder; the raw value stays in env.runner for the // post-script. sandboxEnv := map[string]string{ - "ISSUE_URL": "${GITHUB_ISSUE_URL}", + "ISSUE_URL": "${FULLSEND_WORK_ITEM_URL}", // ISSUE_NUMBER / REPO_FULL_NAME are the fetch arguments the // generated prompt uses. A github.com URL in a `gh` command is // blocked by the SSRF PreToolUse hook: the sandbox cannot @@ -152,7 +152,7 @@ func buildHarness(opts Options, role Role) (*harness.Harness, error) { Trigger: opts.Trigger, Env: &harness.EnvConfig{ Runner: map[string]string{ - "ISSUE_URL": "${GITHUB_ISSUE_URL}", + "ISSUE_URL": "${FULLSEND_WORK_ITEM_URL}", "GH_TOKEN": "${GH_TOKEN}", "FULLSEND_FORGE": "github", }, diff --git a/internal/agentnew/render_test.go b/internal/agentnew/render_test.go index d820f121dd..eea6319ce5 100644 --- a/internal/agentnew/render_test.go +++ b/internal/agentnew/render_test.go @@ -138,6 +138,28 @@ func TestGeneratedHarnessKeepsGHTokenOutOfSandbox(t *testing.T) { } } +// TestGeneratedHarnessUsesWorkItemURL pins the forge-agnostic work item URL +// variable in both env maps. The generated prompt deliberately does not fetch +// by URL, but the post-script still needs it. +func TestGeneratedHarnessUsesWorkItemURL(t *testing.T) { + files, err := Render(testOptions("lint-docs", "triage")) + if err != nil { + t.Fatal(err) + } + dir := t.TempDir() + writeTree(t, dir, files) + h, err := harness.Load(filepath.Join(dir, "harness", "lint-docs.yaml")) + if err != nil { + t.Fatalf("generated harness does not load: %v", err) + } + if got := h.Env.Runner["ISSUE_URL"]; got != "${FULLSEND_WORK_ITEM_URL}" { + t.Errorf("env.runner ISSUE_URL = %q, want ${FULLSEND_WORK_ITEM_URL}", got) + } + if got := h.Env.Sandbox["ISSUE_URL"]; got != "${FULLSEND_WORK_ITEM_URL}" { + t.Errorf("env.sandbox ISSUE_URL = %q, want ${FULLSEND_WORK_ITEM_URL}", got) + } +} + // TestGeneratedHarnessHasNoDeprecatedShapes pins decision 6: no forge: block // (deprecated by ADR 0088) and no runner_env (deprecated by ADR 0055). Lint // would warn, and a generator must never emit a shape the repo has deprecated. diff --git a/internal/agentnew/templates/post.sh.tmpl b/internal/agentnew/templates/post.sh.tmpl index dae55f23e9..e644b3870a 100644 --- a/internal/agentnew/templates/post.sh.tmpl +++ b/internal/agentnew/templates/post.sh.tmpl @@ -9,7 +9,7 @@ # iteration and only the last one counts. # # Required env: -# ISSUE_URL — HTML URL of the work item (the harness maps GITHUB_ISSUE_URL to it) +# ISSUE_URL — HTML URL of the work item (the harness maps FULLSEND_WORK_ITEM_URL to it) # GH_TOKEN — minted by fullsend from the harness `role:` field # # Optional env: diff --git a/internal/agentnew/testdata/golden/codex.txt b/internal/agentnew/testdata/golden/codex.txt index 43b31354e8..90213f92ae 100644 --- a/internal/agentnew/testdata/golden/codex.txt +++ b/internal/agentnew/testdata/golden/codex.txt @@ -77,11 +77,11 @@ env: runner: FULLSEND_FORGE: github GH_TOKEN: ${GH_TOKEN} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} sandbox: FULLSEND_FORGE: github ISSUE_NUMBER: ${ISSUE_NUMBER} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} REPO_FULL_NAME: ${REPO_FULL_NAME} timeout_minutes: 15 trigger: | @@ -160,7 +160,7 @@ trigger: | # iteration and only the last one counts. # # Required env: -# ISSUE_URL — HTML URL of the work item (the harness maps GITHUB_ISSUE_URL to it) +# ISSUE_URL — HTML URL of the work item (the harness maps FULLSEND_WORK_ITEM_URL to it) # GH_TOKEN — minted by fullsend from the harness `role:` field # # Optional env: diff --git a/internal/agentnew/testdata/golden/pi-openai.txt b/internal/agentnew/testdata/golden/pi-openai.txt index 9a54cbf119..dfa7b0fa9b 100644 --- a/internal/agentnew/testdata/golden/pi-openai.txt +++ b/internal/agentnew/testdata/golden/pi-openai.txt @@ -77,11 +77,11 @@ env: runner: FULLSEND_FORGE: github GH_TOKEN: ${GH_TOKEN} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} sandbox: FULLSEND_FORGE: github ISSUE_NUMBER: ${ISSUE_NUMBER} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} REPO_FULL_NAME: ${REPO_FULL_NAME} timeout_minutes: 15 trigger: | @@ -178,7 +178,7 @@ trigger: | # iteration and only the last one counts. # # Required env: -# ISSUE_URL — HTML URL of the work item (the harness maps GITHUB_ISSUE_URL to it) +# ISSUE_URL — HTML URL of the work item (the harness maps FULLSEND_WORK_ITEM_URL to it) # GH_TOKEN — minted by fullsend from the harness `role:` field # # Optional env: diff --git a/internal/agentnew/testdata/golden/triage.txt b/internal/agentnew/testdata/golden/triage.txt index ca4281a7dc..20868072dc 100644 --- a/internal/agentnew/testdata/golden/triage.txt +++ b/internal/agentnew/testdata/golden/triage.txt @@ -85,7 +85,7 @@ env: runner: FULLSEND_FORGE: github GH_TOKEN: ${GH_TOKEN} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} sandbox: ANTHROPIC_VERTEX_PROJECT_ID: ${ANTHROPIC_VERTEX_PROJECT_ID} CLAUDE_CODE_USE_VERTEX: "1" @@ -93,7 +93,7 @@ env: FULLSEND_FORGE: github GOOGLE_APPLICATION_CREDENTIALS: /tmp/.gcp-credentials.json ISSUE_NUMBER: ${ISSUE_NUMBER} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} REPO_FULL_NAME: ${REPO_FULL_NAME} timeout_minutes: 15 trigger: | @@ -172,7 +172,7 @@ trigger: | # iteration and only the last one counts. # # Required env: -# ISSUE_URL — HTML URL of the work item (the harness maps GITHUB_ISSUE_URL to it) +# ISSUE_URL — HTML URL of the work item (the harness maps FULLSEND_WORK_ITEM_URL to it) # GH_TOKEN — minted by fullsend from the harness `role:` field # # Optional env: diff --git a/internal/agentnew/testdata/golden/validation-loop.txt b/internal/agentnew/testdata/golden/validation-loop.txt index 45d55cc540..67438e03ea 100644 --- a/internal/agentnew/testdata/golden/validation-loop.txt +++ b/internal/agentnew/testdata/golden/validation-loop.txt @@ -93,7 +93,7 @@ env: runner: FULLSEND_FORGE: github GH_TOKEN: ${GH_TOKEN} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} sandbox: ANTHROPIC_VERTEX_PROJECT_ID: ${ANTHROPIC_VERTEX_PROJECT_ID} CLAUDE_CODE_USE_VERTEX: "1" @@ -101,7 +101,7 @@ env: FULLSEND_FORGE: github GOOGLE_APPLICATION_CREDENTIALS: /tmp/.gcp-credentials.json ISSUE_NUMBER: ${ISSUE_NUMBER} - ISSUE_URL: ${GITHUB_ISSUE_URL} + ISSUE_URL: ${FULLSEND_WORK_ITEM_URL} REPO_FULL_NAME: ${REPO_FULL_NAME} timeout_minutes: 15 trigger: | @@ -180,7 +180,7 @@ trigger: | # iteration and only the last one counts. # # Required env: -# ISSUE_URL — HTML URL of the work item (the harness maps GITHUB_ISSUE_URL to it) +# ISSUE_URL — HTML URL of the work item (the harness maps FULLSEND_WORK_ITEM_URL to it) # GH_TOKEN — minted by fullsend from the harness `role:` field # # Optional env: diff --git a/internal/cli/agent_new.go b/internal/cli/agent_new.go index 6a8c5d36b5..9bbb6765d1 100644 --- a/internal/cli/agent_new.go +++ b/internal/cli/agent_new.go @@ -333,7 +333,7 @@ func printNextSteps(opts agentnew.Options, f agentNewFlags, printer *ui.Printer) printer.Raw(fmt.Sprintf(" 2. Test locally, printing the result instead of commenting:\n"+ " %s=1 fullsend run %s%s \\\n --target-repo . --env-file .env.local\n", agentnew.DryRunEnvVar(opts.Name), opts.Name, fullsendDirArg(f.fullsendDir))) - printer.Raw(" .env.local needs GITHUB_ISSUE_URL, ISSUE_NUMBER, REPO_FULL_NAME,\n") + printer.Raw(" .env.local needs FULLSEND_WORK_ITEM_URL, ISSUE_NUMBER, REPO_FULL_NAME,\n") switch { case opts.UsesGateway(): printer.Raw(" and GH_TOKEN. The model goes through the inference.gateway block in\n") diff --git a/internal/harness/checkgenerated.go b/internal/harness/checkgenerated.go index d4aff2e73f..0b7b5f266d 100644 --- a/internal/harness/checkgenerated.go +++ b/internal/harness/checkgenerated.go @@ -22,7 +22,7 @@ import ( // Not checked here, on purpose: ValidateRunnerEnvWith. It requires every // ${VAR} in env.runner/env.sandbox to be set in the calling process, which is // true in CI and false on a developer's machine. Failing generation because -// GITHUB_ISSUE_URL is unset would make the command unusable for its main +// FULLSEND_WORK_ITEM_URL is unset would make the command unusable for its main // audience. The consequence is that an unset variable surfaces at // `fullsend run` time instead; the generated docs say so. func CheckGenerated(h *Harness, absDir string) ([]Diagnostic, error) {