Skip to content

[BUG] Standalone Go ADK agent (no KAGENT_URL) fails with "session not found" β€” in-memory session never createdΒ #2193

Description

@braghettos

πŸ“‹ Prerequisites

  • I have searched the existing issues to avoid creating a duplicate
  • By submitting this issue, you agree to follow the Code of Conduct

πŸ› Bug summary

Running the Go ADK agent (go/adk) without KAGENT_URL β€” i.e. standalone / BYO mode with in-memory sessions β€” fails on every message/send with session <id> not found, before any LLM call. The agent never produces a response.

Root cause

When KAGENT_URL is unset, the runner is configured with an in-memory ADK session service:

// go/adk/pkg/runner/adapter.go
var adkSessionService adksession.Service
if sessionService != nil {
    adkSessionService = sessionService
} else {
    adkSessionService = adksession.InMemoryService() // <- nobody creates sessions in this
}

But the A2A executor only creates the session when the kagent session service is wired:

// go/adk/pkg/a2a/executor.go β€” Execute()
if e.sessionService != nil {
    // ... GetSession / CreateSession ...
}
// (no else branch β€” in standalone mode the session is never created)

So runner.Run(ctx, userID, sessionID, ...) looks up a session that was never created and returns session <id> not found. The task ends in state failed.

Reproduction

  1. Build the agent and run it with a minimal config.json (any provider) and no KAGENT_URL:
    CONFIG_DIR=./cfg PORT=8080 GOOGLE_CLOUD_PROJECT=... GOOGLE_CLOUD_LOCATION=us-central1 GOOGLE_GENAI_USE_VERTEXAI=1 ./agent
    # log: "No KAGENT_URL set, using in-memory session and no task persistence"
    
  2. Send an A2A message:
    curl -sX POST -H 'content-type: application/json' \
      -d '{"jsonrpc":"2.0","id":"1","method":"message/send","params":{"message":{"role":"user","parts":[{"kind":"text","text":"hi"}],"messageId":"m1"}}}' \
      http://localhost:8080/
    
  3. The task returns "state":"failed" with "session <contextId> not found".

Suggested fix

In Execute, when e.sessionService == nil, create the session in the runner's session service before running, e.g.:

} else if e.runnerConfig.SessionService != nil {
    _, _ = e.runnerConfig.SessionService.Create(ctx, &adksession.CreateRequest{
        AppName: e.appName, UserID: userID, SessionID: sessionID,
    })
}

(Verified locally: with this, standalone mode completes the LLM call and returns a response.)

🎯 Affected Service(s)

App Service (go/adk agent runtime)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions