Skip to content

fix(substrate): make sandbox agents resume reliably - #2503

Open
Sam123ben wants to merge 3 commits into
kagent-dev:mainfrom
Sam123ben:agent/substrate-compatibility
Open

fix(substrate): make sandbox agents resume reliably#2503
Sam123ben wants to merge 3 commits into
kagent-dev:mainfrom
Sam123ben:agent/substrate-compatibility

Conversation

@Sam123ben

Copy link
Copy Markdown

What changed\n\n- resolve desired Secret stringData when building the Substrate ActorTemplate\n- explicitly cold-boot from durable data on resume\n- give the actor readiness probe a 30-second timeout\n- add regression coverage for all three compatibility requirements\n\n## Why\n\nA generated SandboxAgent could remain unready because a not-yet-persisted Secret only exposed stringData, resume omitted the required source, and the default readiness timeout was too short for the actor.\n\n## Validation\n\n- go test -race ./core/pkg/sandboxbackend/substrate\n- go vet ./core/pkg/sandboxbackend/substrate\n- go build ./core/pkg/sandboxbackend/substrate\n- gofmt check on changed Go files\n- isolated gVisor canary reached Accepted=True and Ready=True

@Sam123ben
Sam123ben requested a review from a team as a code owner August 19, 2026 20:54
Signed-off-by: sam123ben <samyak.rout@gmail.com>
Signed-off-by: sam123ben <samyak.rout@gmail.com>
Signed-off-by: sam123ben <samyak.rout@gmail.com>
@Sam123ben

Copy link
Copy Markdown
Author

Additional security and runtime validation in f13d370d:

  • Upgraded A2A Go to v2.5.0 with a regression test for single-object JSON-RPC error.data.
  • Fixed durable SandboxAgent Actor identity so it is scoped to authenticated owner + session, not session alone.
  • Missing owner identity and failed session attribution now fail closed before Actor creation.
  • Suspend/delete use the same owner-scoped identity.

Evidence:

  • Red/green regression for two owners sharing one external session ID.
  • Isolated Substrate run produced two distinct opaque Actor IDs for Alice and Bob using the same contextId.
  • Full A2A cold-Actor path returned The answer is 4. with 218.6 ms restore and 411.7 ms total response time.
  • go test -race for affected packages passed.
  • go build ./..., go vet ./..., and make lint passed (0 issues).
  • Full go test ./core/... passed except the existing macOS /var vs /private/var path-canonicalization failures in core/v2/agentplugins.

@Sam123ben

Sam123ben commented Aug 19, 2026

Copy link
Copy Markdown
Author

@EItanya maintainer action requested: the current head f13d370d is mergeable, DCO/Snyk and the documented local race/build/vet/lint plus isolated Actor acceptance are green. GitHub has left CI Build and UI Playwright at action_required for this fork contribution; please approve those workflow runs and review when available. --admin merge was attempted by the author account but correctly rejected for lack of upstream merge permission.

@Sam123ben

Copy link
Copy Markdown
Author

CI diagnosis update:

The two red jobs are a shared upstream previous-stable regression, not introduced by this PR.

All substrate-focused tests, unit/race validation, lint, builds, E2E, DCO, and adjacent-upgrade jobs remain green. A maintainer rerun or an upstream 0.10.0-rc3 -> main upgrade-path fix is needed independently of this PR.

// Persist owner-scoped session metadata before creating or resuming an actor.
// Failing closed keeps untracked sessions out of the shared sandbox runtime.
if err := t.ensureSessionRow(req.Context(), sessionID, userID); err != nil {
return nil, fmt.Errorf("ensure controller session row: %w", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was best effort before, now a db write failure blocks the whole chat request. a short postgres hiccup now breaks every substrate agent, not just session listing. intended tradeoff?

}
userID := strings.TrimSpace(req.Header.Get("X-User-Id"))
if userID == "" {
return nil, fmt.Errorf("request carries no user identity")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now hard requires X-User-Id on every request through this transport. are all callers of this roundtripper guaranteed to go through auth middleware first, including any internal or background caller?

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants