Skip to content

Expose the gated tool-call id on session.PendingAsk #148

Closed

Description

@JAORMX

Summary

session.PendingAsk (engine/session/session.go:181) carries AskID, Tool,
Args, Reason, and two governance booleans — but not the id of the tool call
the ask gates. A host that pauses on a PendingAsk and needs the gated
tool-call id recovers it today by splitting the AskID string on : and taking
the third field.

Why this is wrong

The verdict-side value object already exposes this. session.ApprovalPayload
carries Call ToolCallID as a first-class field (engine/session/event.go),
and its own doc says the id is "already implicitly encoded inside AskID." The
pause-side value object should be symmetric.

Forcing the host to parse the AskID grammar couples it to a format the engine
treats as partly internal. newAskID (engine/agent/dispatch.go:1122)
documents only the leading <sessionID>: prefix as a consumed contract; the
<n> and :r<serial> components are implementation detail. A host that reads
field 3 breaks silently if the layout ever changes.

Evidence (consumer)

Atrium does exactly this in its engine adapter. gatedToolCallID in
internal/modules/agentloop/app/engine/driver.go runs
strings.Split(ask.AskID, ":")[2] to recover the gated call id
(stacklok/atrium#552).

Proposed change

Add Call ToolCallID to session.PendingAsk, populated where the ask is minted
(dispatch.go, alongside AskID). Additive, non-breaking — a minor bump per
COMPATIBILITY.md.

Implementation notes (verified against current main)

  • Mint site (the core change). engine/agent/dispatch.go:508 builds the
    PendingAsk. Add Call: c.ID — c is the session.ToolCall in scope, and
    the sibling EvApproval emit at dispatch.go:551 already uses Call: c.ID,
    so this just makes the pause side symmetric with the verdict side.
  • Second surfaced-ask site. engine/agent/dispatch.go:943 builds a
    PendingAsk for the surfaced child/subagent ask. Populate Call there too
    from that scope's gated call id.
  • Leave the retract sites alone. engine/agent/childregistry.go:731 and
    :807 build PendingAsk{AskID: ...} for EvPermissionRetract, which by
    contract carries the AskID only. Do not add Call there.
  • Snapshot round-trip. The snapshot DTO serialises the whole struct
    (engine/adapter/sessnap/sessnap.go:41 — Pending *session.PendingAsk,
    json:"pending,omitempty"). Call is durable correlation data, unlike the
    run-scoped ConfiguredAsk/FlooredConfiguredAllow, so it should round-trip.
    Give it a normal json tag (follow the neighbouring fields), not json:"-",
    and confirm the sessnap round-trip test covers it.

Acceptance

  • session.PendingAsk has a Call ToolCallID field, populated on every pause
    on both the main-agent path and the surfaced-child path.
  • A test asserts the field equals the ToolCall.ID the dispatch gated.
  • task api:update regenerated engine/api/session.txt (the field appears);
    task api:check passes.
  • A CHANGELOG entry lands under [Unreleased] → Added (additive = minor per
    COMPATIBILITY.md).

Context

Surfaced reviewing the engine import (stacklok/atrium#552). The broader question
— that the askID is not reconstructable across processes because of a
process-global serial — is tracked separately in #117 and is out of scope
here
. This issue is the small, independently-shippable half: expose the field
the host actually needs so it stops parsing the grammar.

Paired Atrium cleanup that removes the parse once this lands: stacklok/atrium#581.

Activity

  1. added
    enhancement
    atrium-convergence
    on Jun 22, 2026
  2. JAORMX commented on Jun 22, 2026

    @JAORMX
    ContributorAuthor

    Paired Atrium cleanup that removes the grammar-parse once this lands: stacklok/atrium#581. Design question on cross-process reconstructability: #117.

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

    atrium-convergenceenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions