MCPcopy Index your code
hub / github.com/google/adk-go

github.com/google/adk-go @v2.0.0

repository ↗ · DeepWiki ↗ · release v2.0.0 ↗ · + Follow
17,933 symbols 77,267 edges 581 files 2,091 documented · 12%
README

Agent Development Kit (ADK) for Go v 2.0

License

Breaking changes

session.NewEvent now requires a context.Context

session.NewEvent takes a context.Context as its first argument:

func NewEvent(ctx context.Context, invocationID string) *Event

The event ID and timestamp are now obtained through the platform package, so a time or UUID provider installed on ctx (see platform.WithTimeProvider and platform.WithUUIDProvider) controls them. This lets callers such as workflow engines produce deterministic, replay-safe events.

The previous parameterless-context form and the temporary NewEventWithContext helper are gone. Migrate by passing the context that is already in scope:

// Before
ev := session.NewEvent(ctx.InvocationID())
// or
ev := session.NewEventWithContext(ctx, ctx.InvocationID())

// After
ev := session.NewEvent(ctx, ctx.InvocationID())

Any context.Context works as the first argument: the ctx of an agent/tool/ callback (which embed context.Context), the incoming RPC/HTTP request context, or — in tests — t.Context(). As the context package advises, thread the context down the call chain rather than creating one with context.Background() in the middle of it; reserve context.Background() for main, init, and top-level test/setup code.

If you call NewEvent from a helper that does not yet receive a context, add a ctx context.Context parameter to that helper and pass it through from its callers.

Mocks update required for unified contexts

PR https://github.com/google/adk-go/pull/945 merges ToolContext and CallbackContext into single Context.

This introduces a problem for mock contexts - new functions (ToolContext-related) are missing if the mock was created for the previous version of CallbackContext. Solution: Add those functions to your mock:

func (m *MockCallbackContext) Actions() *session.EventActions                       { return nil }
func (m *MockCallbackContext) FunctionCallID() string                               { return "" }
func (m *MockCallbackContext) ToolConfirmation() *toolconfirmation.ToolConfirmation { return nil }
func (m *MockCallbackContext) RequestConfirmation(hint string, payload any) error {
    return fmt.Errorf("RequestConfirmation() is not supported for MockCallbackContext")
}
func (m *MockCallbackContext) SearchMemory(ctx context.Context, query string) (*memory.SearchResponse, error) {
    return nil, fmt.Errorf("SearchMemory() is not supported for MockCallbackContext")
}

var _ agent.Context = (*MockCallbackContext)(nil)

Alternative: embed agent.StrictContextMock

Adding each missing method by hand is reactive: every time the context surface grows, your mocks break again and you have to patch them. Instead, you can embed agent.StrictContextMock in your test fake and override only the methods your test actually uses. Because it implements the whole unified context surface, embedders keep compiling as the interface grows — no further edits needed when methods are added.

Un-overridden methods panic with "not implemented", so an unexpected call fails the test loudly instead of silently returning a zero value. The standard context.Context methods (Deadline, Done, Err, Value) read from the supplied Ctx rather than panicking.

Assert against the unified agent.Context directly.

// Embed StrictContextMock and override only what the test needs.
type fakeContext struct {
    agent.StrictContextMock
}

var _ agent.Context = (*fakeContext)(nil)

func TestSomething(t *testing.T) {
    cc := &fakeContext{agent.StrictContextMock{Ctx: context.Background()}}
    // Override methods as needed, e.g. by adding them on fakeContext.
    // ...
}

Extension points exported contracts — how you extend this code

LLM (Interface)
LLM provides the access to the underlying LLM. [22 implementers]
model/llm.go
Session (Interface)
Session represents a series of interactions between a user and agents. When a user starts interacting with your agent, [15 …
session/session.go
AgentLike (Interface)
AgentLike is the minimal contract telemetry needs to describe a BaseAgent. [30 implementers]
internal/telemetry/node_tracing.go
Sublauncher (Interface)
Sublauncher defines an interface for extending the WebLauncher. Each sublauncher can add its own routes, wrap existing h [6 …
cmd/launcher/web/web.go
Router (Interface)
Router defines the required methods for retrieving api routes [8 implementers]
server/adkrest/internal/routers/routers.go
MethodHandler (Interface)
MethodHandler is an interface which provides a structured way to serve methods on agentEngine [6 implementers]
server/agentengine/controllers/method/method.go
Runner (Interface)
Runner is an interface matching [runner.Runner] API. It exists to let users use custom runner implementations with A2A a [74 …
server/adka2a/v2/executor.go
Validator (Interface)
Validator describes a type that can validate itself. [7 implementers]
artifact/request_validation_test.go

Core symbols most depended-on inside this repo

push
called by 2823
cmd/launcher/web/webui/distr/main-I3DI43ZQ.js
g
called by 2288
cmd/launcher/web/webui/distr/main-I3DI43ZQ.js
I
called by 1441
cmd/launcher/web/webui/distr/chunk-JUE6OUNA.js
h
called by 1398
cmd/launcher/web/webui/distr/chunk-7BGAJP6A.js
Q
called by 1137
cmd/launcher/web/webui/distr/chunk-JUE6OUNA.js
p
called by 1126
cmd/launcher/web/webui/distr/chunk-KDOJMYWA.js
get
called by 1033
cmd/launcher/web/webui/distr/main-I3DI43ZQ.js
y
called by 980
cmd/launcher/web/webui/distr/chunk-5JNRF4JL.js

Shape

Function 9,833
Method 7,053
Struct 724
Class 159
Interface 65
FuncType 63
TypeAlias 36

Languages

TypeScript74%
Go26%

Modules by API surface

cmd/launcher/web/webui/distr/main-I3DI43ZQ.js6,844 symbols
cmd/launcher/web/webui/distr/chunk-2SRK2U7X.js1,751 symbols
cmd/launcher/web/webui/distr/chunk-7ZGKZ6HH.js1,329 symbols
cmd/launcher/web/webui/distr/chunk-JRNAXTJ7.js584 symbols
cmd/launcher/web/webui/distr/chunk-YVVLWU7S.js545 symbols
cmd/launcher/web/webui/distr/chunk-27SWUPRL.js262 symbols
cmd/launcher/web/webui/distr/chunk-YEJ3ZE5E.js138 symbols
cmd/launcher/web/webui/distr/polyfills-5CFQRCPP.js134 symbols
cmd/launcher/web/webui/distr/chunk-ZMOC4H7T.js116 symbols
cmd/launcher/web/webui/distr/chunk-4V3PIBXT.js113 symbols
cmd/launcher/web/webui/distr/chunk-NRMNZ7EH.js90 symbols
cmd/launcher/web/webui/distr/chunk-2UTQOSKI.js77 symbols

Dependencies from manifests, versioned

cel.dev/exprv0.25.1 · 1×
cloud.google.com/gov0.123.0 · 1×
cloud.google.com/go/aiplatformv1.121.0 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.8 · 1×
cloud.google.com/go/compute/metadatav0.9.0 · 1×
cloud.google.com/go/longrunningv0.8.0 · 1×
cloud.google.com/go/monitoringv1.24.3 · 1×
cloud.google.com/go/storagev1.56.1 · 1×
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcpv1.31.0 · 1×
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metricv0.53.0 · 1×

For agents

$ claude mcp add adk-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact