agent: consolidate context implementations in-place (alternative to P…#823
Draft
wolo-lab wants to merge 1 commit into
Draft
agent: consolidate context implementations in-place (alternative to P…#823wolo-lab wants to merge 1 commit into
wolo-lab wants to merge 1 commit into
Conversation
…#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.
ed246a5 to
ea4fbfa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…R #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):
What's removed:
Trade-off vs the canonical PR #1:
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
If applicable, please follow the issue templates to provide as much detail as
possible.
Problem:
A clear and concise description of what the problem is.
Solution:
A clear and concise description of what you want to happen and why you choose
this solution.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.
Unit Tests:
Please include a summary of passed go test results.
Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any
necessary setup or configuration. Please provide logs or screenshots to help
reviewers better understand the fix.
Checklist
Additional context
Add any other context or screenshots about the feature request here.