Skip to content

Initial commit of Go ADK#2

Merged
rakyll merged 1 commit into
mainfrom
initial
May 20, 2025
Merged

Initial commit of Go ADK#2
rakyll merged 1 commit into
mainfrom
initial

Conversation

@rakyll
Copy link
Copy Markdown
Member

@rakyll rakyll commented May 19, 2025

No description provided.

@rakyll rakyll requested a review from cornellgit May 19, 2025 21:41
Comment thread agent/agent.go
Comment thread agent/agent.go
@rakyll rakyll merged commit eee4c74 into main May 20, 2025
1 check passed
@rakyll rakyll deleted the initial branch May 20, 2025 00:28
davidli2010 pushed a commit to davidli2010/adk-go that referenced this pull request Feb 4, 2026
wolo-lab added a commit that referenced this pull request May 12, 2026
…rs to import agent directly

Sweeps the 28 importers of internal/context (alias 'icontext' or
'contextinternal') to use agent.NewX directly. The alias layer
introduced in PR #1 was a transitional stage; with PR #2 (unified
agent.Context interface) landed, no consumer needs internal/context
any more.

Mechanical changes:

  * `icontext.NewInvocationContext` → `agent.NewInvocationContext` (most uses)
  * `icontext.InvocationContextParams` → `agent.InvocationContextParams`
  * `icontext.NewCallbackContext` → `agent.NewCallbackContext` (2 uses)
  * `icontext.NewCallbackContextWithDelta` → `agent.NewCallbackContextWithDelta` (8 uses)
  * `icontext.NewReadonlyContext` → `agent.NewReadonlyContext` (3 uses)

Per-file: 28 importer files lose their `icontext "…/internal/context"`
import line. `internal/toolinternal/context_test.go` had a different
alias name (`contextinternal`); also rewritten.

One ad-hoc fix: `agent/remoteagent/v2/utils_test.go` had a local
variable named `agent` shadowing the package name; renamed to `a`
(unrelated to the sweep but exposed by it).

Then deletes `internal/context/` entirely. The package no longer
exists; `agent` is the single home for canonical context constructors.

Verified: go build ./...; go vet ./...; go test ./...; all pass.
wolo-lab added a commit that referenced this pull request May 12, 2026
…#1)

Same goal as wolo/context_unif_v2_pr1_move (eliminate the 3 pairs of
duplicate context impls + the duplicate internalArtifacts helper),
opposite execution: keeps existing implementations in agent/agent.go
instead of moving them to new files.

What's added to agent/agent.go (~146 lines):
  * internalArtifacts wrapper (delta-tracking for Save).
  * NewCallbackContext / NewCallbackContextWithDelta constructors.
  * artifacts field on callbackContext + updated Artifacts() to return
    the wrapper (bug fix: previously returned unwrapped Artifacts, so
    Save() in callbacks didn't record into EventActions.ArtifactDelta).
  * NewInvocationContext + InvocationContextParams.
  * readonlyContext struct + 8 methods + NewReadonlyContext.
  * InvocationOf helper (returns underlying InvocationContext from
    a NewReadonlyContext-produced ReadonlyContext).
  * runBeforeAgentCallbacks / runAfterAgentCallbacks switched from
    raw struct literal to newCallbackContextImpl (no behavioural
    change — the new bug fix takes effect either way).

What's removed:
  * internal/context/{invocation,callback,readonly}_context.go shrink
    to thin alias layers (var NewX = agent.NewX).
  * internal/context/context_test.go deleted (its TestWithContext
    sibling already exists in agent/agent_test.go; the other two
    tests can be re-added in agent/ if desired).
  * internal/toolinternal.internalArtifacts dropped (toolContext now
    relies on the embedded CallbackContext for Artifacts wrapping —
    eliminates double-wrapping bug).
  * util/instructionutil drops the icontext import; uses
    agent.InvocationOf instead of *icontext.ReadonlyContext type
    assertion.

Trade-off vs the canonical PR #1:
  * agent/agent.go grows from 521 to ~660 lines (mixing Agent + Run
    + Context impls + helpers in one file).
  * 7 files touched instead of 13; +168/-352 = -184 lines net,
    versus +489/-537 = -48 net for PR #1. ~136 lines smaller diff.
  * No new files in agent/ (3 fewer in git status).

This branch exists for comparison; whichever direction we pick gets
PRs #2 and #3 stacked on top.

Verified: go build ./...; go vet ./...; go test ./...; all pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants