Skip to content

Commit 7e8ec03

Browse files
committed
refactor: rename AgentContext.EntranceType to InvocationType, fix golang ci lint
1 parent 000dc68 commit 7e8ec03

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

adk/agent_middleware.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ type AgentContext struct {
9595
AgentRunOptions []AgentRunOption
9696

9797
// internal properties, read only
98-
agentName string
99-
entrance InvocationType
98+
agentName string
99+
invocationType InvocationType
100100
}
101101

102102
func (a *AgentContext) AgentName() string {
103103
return a.agentName
104104
}
105105

106-
func (a *AgentContext) EntranceType() InvocationType {
107-
return a.entrance
106+
func (a *AgentContext) InvocationType() InvocationType {
107+
return a.invocationType
108108
}
109109

110110
func isAgentMiddlewareEnabled(a Agent) bool {

adk/agent_middleware_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,12 @@ func TestRunnerWithMWCallbacks(t *testing.T) {
582582
}
583583
mw2 := AgentMiddleware{
584584
BeforeAgent: func(ctx context.Context, ac *AgentContext) (nextContext context.Context, err error) {
585-
if ac.EntranceType() == InvocationTypeRun {
585+
if ac.InvocationType() == InvocationTypeRun {
586586
assert.Equal(t, "Hi", ac.AgentInput.Messages[0].Content)
587-
} else if ac.EntranceType() == InvocationTypeResume {
587+
} else if ac.InvocationType() == InvocationTypeResume {
588588
assert.NotNil(t, ac.ResumeInfo)
589589
} else {
590-
assert.Fail(t, "invalid entrance")
590+
assert.Fail(t, "invalid invocationType")
591591
}
592592
return ctx, nil
593593
},

adk/chatmodel.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func WithAgentToolRunOptions(opts map[string] /*tool name*/ []AgentRunOption) Ag
8181
})
8282
}
8383

84+
// WithGraphCallbacks sets callback handlers for internal graph / chain execution.
8485
func WithGraphCallbacks(callbacks ...callbacks.Handler) AgentRunOption {
8586
return WrapImplSpecificOptFn(func(t *chatModelAgentRunOptions) {
8687
t.graphCallbacks = callbacks
@@ -872,7 +873,7 @@ func (a *ChatModelAgent) Run(ctx context.Context, input *AgentInput, opts ...Age
872873
AgentInput: input,
873874
AgentRunOptions: opts,
874875
agentName: a.name,
875-
entrance: InvocationTypeRun,
876+
invocationType: InvocationTypeRun,
876877
}
877878

878879
mwHelper, run := a.buildRunFunc(ctx)
@@ -910,7 +911,7 @@ func (a *ChatModelAgent) Resume(ctx context.Context, info *ResumeInfo, opts ...A
910911
ResumeInfo: info,
911912
AgentRunOptions: opts,
912913
agentName: a.name,
913-
entrance: InvocationTypeResume,
914+
invocationType: InvocationTypeResume,
914915
}
915916

916917
mwHelper, run := a.buildRunFunc(ctx)

adk/flow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (a *flowAgent) Run(ctx context.Context, input *AgentInput, opts ...AgentRun
306306
AgentInput: input,
307307
AgentRunOptions: opts,
308308
agentName: agentName,
309-
entrance: InvocationTypeRun,
309+
invocationType: InvocationTypeRun,
310310
}
311311
)
312312

@@ -357,7 +357,7 @@ func (a *flowAgent) Resume(ctx context.Context, info *ResumeInfo, opts ...AgentR
357357
ResumeInfo: info,
358358
AgentRunOptions: opts,
359359
agentName: agentName,
360-
entrance: InvocationTypeRun,
360+
invocationType: InvocationTypeRun,
361361
}
362362
)
363363

adk/multi_agent.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type MultiAgentConfig struct {
2828
Middlewares []AgentMiddleware // optional
2929
}
3030

31-
// The NewMultiAgent method enables wrapping any individual Agent into a Multi-Agent structure.
31+
// NewMultiAgent enables wrapping any individual Agent into a Multi-Agent structure.
3232
// It assigns a new Name and Description to the wrapped Agent and adds middleware-based runtime capabilities around it.
3333
// This method is essentially a simple wrapper for Agents, designed to address the following specific use cases:
3434
// 1. Customizing Agent Metadata: Modify the public-facing Name and Description of any existing Agent, while adding middleware to its execution flow.
@@ -74,7 +74,7 @@ func (ma *multiAgent) Run(ctx context.Context, input *AgentInput, options ...Age
7474
AgentInput: input,
7575
AgentRunOptions: options,
7676
agentName: ma.name,
77-
entrance: InvocationTypeRun,
77+
invocationType: InvocationTypeRun,
7878
}
7979

8080
mwHelper := newAgentMWHelper(append(globalAgentMiddlewares, ma.middlewares...)...)
@@ -94,7 +94,7 @@ func (ma *multiAgent) Resume(ctx context.Context, info *ResumeInfo, opts ...Agen
9494
ResumeInfo: info,
9595
AgentRunOptions: opts,
9696
agentName: ma.name,
97-
entrance: InvocationTypeResume,
97+
invocationType: InvocationTypeResume,
9898
}
9999

100100
mwHelper := newAgentMWHelper(append(globalAgentMiddlewares, ma.middlewares...)...)

adk/multi_agent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestMultiAgent(t *testing.T) {
5454
Name: "test",
5555
BeforeAgent: func(ctx context.Context, ac *AgentContext) (nextContext context.Context, err error) {
5656
assert.Equal(t, "mock_name", ac.AgentName())
57-
assert.Equal(t, InvocationTypeRun, ac.EntranceType())
57+
assert.Equal(t, InvocationTypeRun, ac.InvocationType())
5858
assert.Equal(t, "hello", ac.AgentInput.Messages[0].Content)
5959

6060
ac.AgentInput.Messages[0].Content = "bye"

adk/workflow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (a *workflowAgent) Run(ctx context.Context, input *AgentInput, opts ...Agen
6666
AgentInput: input,
6767
AgentRunOptions: opts,
6868
agentName: a.name,
69-
entrance: InvocationTypeRun,
69+
invocationType: InvocationTypeRun,
7070
}
7171
)
7272

@@ -136,7 +136,7 @@ func (a *workflowAgent) Resume(ctx context.Context, info *ResumeInfo, opts ...Ag
136136
ResumeInfo: info,
137137
AgentRunOptions: opts,
138138
agentName: a.name,
139-
entrance: InvocationTypeRun,
139+
invocationType: InvocationTypeRun,
140140
}
141141
)
142142

0 commit comments

Comments
 (0)