Skip to content

Session link in GitHub issue/PR footers should be dynamically generated #660

Closed

Description

@dcramer

Problem

The session link added to GitHub issue and PR bodies is currently hardcoded in skill instructions (sentry.sentry.io, project ID 4510944073809921). This is:

  • Only valid for Sentry's own internal deployment
  • Broken for any user with a self-hosted or differently-configured SENTRY_DSN
  • Using a stale URL path (/traces/?query=) instead of the correct /explore/conversations/{id}/ route

The skill-level template has been removed in #659 as a stop-gap.

Desired behavior

The session link should be dynamically constructed from the runtime's Sentry config (DSN + org slug) and injected into PR/issue bodies by the app — not hardcoded into agent skill instructions.

buildSentryConversationUrl() in packages/junior/src/chat/sentry-links.ts already builds the correct URL from runtime DSN config. The app needs a way to surface this to the github-code and github-issues skills at execution time, either via:

  • Runtime context injection (e.g. a sentry_session_url field in the turn context passed to skills)
  • App-level post-processing that appends the footer after the model writes the body
  • A dedicated tool the model can call to retrieve the session URL

Notes

  • buildSentryConversationUrl() uses SENTRY_ORG_SLUG env + DSN to build the right URL for any deployment
  • The correct URL format is explore/conversations/{url-encoded-id}/?project={project_id}

Activity

  1. added
    enhancement
    on Jun 28, 2026
  2. dcramer commented on Jun 29, 2026

    @dcramer
    MemberAuthor

    Proposed direction: deterministic provider writes via typed GitHub tools

    After talking through the plugin/runtime constraints, the cleanest solution does not look like a generic HTTP body rewrite layer. The better shape is to make deterministic GitHub writes a typed plugin/tool boundary and share the existing credentialed egress path with host/plugin tools.

    Problem framing

    Today GitHub issue/PR creation is effectively skill-driven shell behavior, usually through gh issue create, gh pr create, gh api, or equivalent HTTP calls from the sandbox. That means the model owns the final body text, and the runtime only owns credential injection.

    Prompting the model to include a footer is therefore best-effort, not deterministic. A shell command can also bypass any command-level wrapper by using curl, gh api, GraphQL, or a script.

    The enforcement boundary we already have is the egress credential path: GitHub credentials are injected by Junior, not placed directly in the sandbox. So deterministic output needs to move GitHub writes behind a runtime/plugin-owned action boundary.

    Proposed architecture

    1. Extract a shared credentialed egress engine from the current sandbox egress proxy.

      This shared engine should own the parts that are currently coupled to sandbox proxy handling:

      • provider resolution
      • plugin grantForEgress selection
      • plugin issueCredential
      • credential context / actor / delegated subject handling
      • credential header transforms
      • upstream request execution
      • plugin onEgressResponse
      • auth-required and permission-denied normalization

      The existing sandbox proxy should become one caller of this engine, not the only place where credentialed provider requests can happen.

    2. Add a host-only plugin egress client.

      Plugin runtime/tool code should be able to make provider requests through the same credential path without forcing the request to originate in the sandbox only to get credential interception.

      Example shape, exact API not finalized:

      await ctx.egress.fetch({
        provider: "github",
        operation: "github.issue.create",
        request: new Request(
          "https://api.github.com/repos/getsentry/junior/issues",
          {
            method: "POST",
            headers: {
              Accept: "application/vnd.github+json",
              "Content-Type": "application/json",
            },
            body,
          },
        ),
      });

      Important: this should be available to plugin runtime code, not directly to the model.

    3. Add typed GitHub write tools.

      Start with a model-visible tool such as:

      github.createIssue({
        repo,
        title,
        body,
        labels,
      })

      The tool would:

      • validate structured args
      • construct the deterministic session/footer URL from runtime context, e.g. via buildSentryConversationUrl() or a future generic conversation-link hook
      • append or merge the footer into the issue body in host/plugin code
      • call GitHub's basic REST API shape directly through ctx.egress.fetch
      • return the canonical issue number and URL

      This avoids relying on gh issue create flags, temp files, CLI behavior, or HTTP request rewriting.

    4. Deny protected GitHub writes from raw sandbox shell by default.

      Since shell can otherwise bypass a typed tool, the egress layer should classify protected GitHub write requests and refuse to inject write credentials for those requests unless they come from an approved runtime-owned path.

      Initial protected operations should include at least:

      • POST /repos/:owner/:repo/issues
      • PATCH /repos/:owner/:repo/issues/:number when changing body/title/state/labels as policy requires
      • issue comments if we decide they also need deterministic runtime-owned content
      • PR creation endpoints when the PR footer case is addressed
      • relevant GraphQL mutations

      Reads can continue to work from shell through normal sandbox egress.

    5. Account for GraphQL bypasses.

      GitHub issue creation can be done through GraphQL mutations, not only REST. The existing GitHub plugin already inspects GraphQL request bodies for query/mutation classification under a body-size cap. Protected-write enforcement needs to extend that classification.

      Proposed policy:

      • GraphQL queries: continue through normal read/write grant classification as appropriate.
      • GraphQL mutations/subscriptions from sandbox shell: treat as protected writes and deny by default unless a future permit mechanism allows them.
      • Known protected mutations should be explicitly classified where feasible, e.g. createIssue, updateIssue, createPullRequest, updatePullRequest, addComment.
      • Unknown GraphQL mutations should fail closed from shell, because otherwise they are an easy bypass around typed write tools.
    6. Optional future: JWT write permits for sandbox-originated approved writes.

      If we later need a typed tool to intentionally delegate a protected write back into the sandbox, we can add a second short-lived signed permit rather than weakening the default denial.

      Example claims:

      {
        "typ": "junior.egress.write.v1",
        "aud": "junior.egress",
        "provider": "github",
        "operation": "github.issue.create",
        "egress_id": "...",
        "method": "POST",
        "host": "api.github.com",
        "path": "/repos/getsentry/junior/issues",
        "body_sha256": "...",
        "iat": 1234567800,
        "exp": 1234567860
      }

      We discussed JWT-only permits as acceptable if replay within a very short TTL is not a concern. This can wait if host/plugin ctx.egress.fetch covers the typed create path.

    Why not generic HTTP rewrite?

    A rewrite layer is enforceable, but it is the wrong primary abstraction:

    • it has to understand REST, GraphQL, gh behavior, body encodings, and retries
    • it mixes product output policy into the credential proxy
    • it is harder to reason about than a typed create/update API
    • it can silently mutate model-created content instead of making runtime ownership explicit

    The egress layer should enforce whether a write is allowed. The typed GitHub tool should own the final body.

    Open design decisions

    These still need to be decided before implementation:

    • Exact ctx.egress.fetch API shape and where it lives in @sentry/junior-plugin-api.
    • Whether ctx.egress.fetch should require an explicit provider and operation, or infer provider from URL and use operation only for diagnostics/policy.
    • How host/plugin egress surfaces auth-required state so the existing OAuth pause/resume flow works outside sandbox bash execution.
    • Which GitHub write operations are blocked from raw shell immediately versus migrated gradually for compatibility.
    • Whether issue comments require deterministic footer/content policy, or only issue/PR creation bodies do.
    • How to treat git smart HTTP push. It is a write, but it likely needs a separate policy from issue/PR API writes.
    • Whether protected GraphQL mutation denial should be blanket or maintain a narrower mutation allow/deny list.
    • Whether the deterministic footer should be Sentry-specific via current config, generic via a conversation-link hook, or both.
    • Whether PR creation should be included in the first slice or follow after issue creation.

    Suggested first vertical slice

    1. Extract the shared credentialed egress engine enough to support both sandbox proxy and host/plugin calls.
    2. Add host-only ctx.egress.fetch to plugin tool context.
    3. Implement github.createIssue using GitHub REST directly.
    4. Append the session/conversation footer in the tool before the request is sent.
    5. Update the github-issues skill to use github.createIssue for creation.
    6. Deny raw sandbox GitHub issue creation through REST and GraphQL mutation paths.
    7. Add tests proving:
      • existing sandbox read egress still works
      • host/plugin egress uses the existing GitHub credential hooks
      • github.createIssue appends the footer deterministically
      • raw shell gh issue create / REST create is denied
      • GraphQL mutation create paths are denied from shell

    This makes deterministic issue bodies runtime-owned, preserves one credential implementation path, and avoids turning the HTTP proxy into a general content rewriter.

  3. dcramer commented on Jun 29, 2026

    @dcramer
    MemberAuthor

    Suggested PR slicing

    I think the best first slice is a behavior-preserving extraction of shared credentialed egress, before adding any new GitHub tool or enforcement policy.

    Proposed PR order:

    1. Shared credentialed egress engine

      • Extract the reusable provider request path from sandbox/egress-proxy.ts.
      • Keep the sandbox proxy as the only caller.
      • Preserve current auth-required signals, permission-denied signals, response hooks, logging, and GraphQL grant classification.
      • No plugin API changes yet.
    2. Host/plugin egress API

      • Add host-only ctx.egress.fetch to plugin tool context.
      • Route it through the shared egress engine.
      • Define how auth-required/permission-denied surfaces from non-shell plugin tools.
    3. Typed GitHub createIssue tool

      • Add github.createIssue using GitHub REST through ctx.egress.fetch.
      • Render deterministic session/conversation footer in plugin/runtime code.
      • Keep raw shell writes unchanged initially if needed to minimize blast radius.
    4. Skill migration

      • Update github-issues skill to use github.createIssue for creation.
      • Add model-facing coverage that issue creation chooses the typed tool.
    5. Protected write enforcement

      • Deny sandbox-originated protected GitHub issue/PR write paths once typed replacements exist.
      • Include REST and GraphQL mutation bypass coverage.
      • Treat git smart HTTP push as separate policy.

    This avoids introducing blocking policy before the replacement path exists, and gives reviewers one concern per PR.

  4. 14 remaining items

  5. dcramer commented on Jun 30, 2026

    @dcramer
    MemberAuthor

    Fixed by the typed GitHub write path work: host/plugin credentialed egress (#685), typed issue creation with runtime-owned session footer (#687), raw issue creation denial (#689), and typed PR creation with runtime-owned session footer (#690).

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

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions