Collapse RunWithOpts duplicates into variadic options
Run, RunStreamed, and Resume each shipped both a no-options form and a mirror *WithOpts form taking variadic RunOption. Variadic parameters are backward-compatible additions, so the wrappers were dead surface. Make Run, RunStreamed, and Resume directly variadic and update the two internal callers. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -480,7 +480,7 @@ func TestRestore(t *testing.T) {
|
||||
close(stopCh)
|
||||
ctx := agent.WithStopSignal(context.Background(), stopCh)
|
||||
|
||||
_, err := ag.RunWithOpts(
|
||||
_, err := ag.Run(
|
||||
ctx,
|
||||
[]llm.Message{
|
||||
{
|
||||
|
||||
@@ -115,11 +115,7 @@ func blockingCallLLM(ctx context.Context, agent *Agent, req *llm.ChatCompletionR
|
||||
return acc.Response(), nil
|
||||
}
|
||||
|
||||
func (a *Agent) Run(ctx context.Context, messages []llm.Message) (*Result, error) {
|
||||
return a.RunWithOpts(ctx, messages)
|
||||
}
|
||||
|
||||
func (a *Agent) RunWithOpts(ctx context.Context, messages []llm.Message, opts ...RunOption) (*Result, error) {
|
||||
func (a *Agent) Run(ctx context.Context, messages []llm.Message, opts ...RunOption) (*Result, error) {
|
||||
ro := runOpts{
|
||||
callLLM: blockingCallLLM,
|
||||
onEvent: noopEvent,
|
||||
@@ -1244,11 +1240,7 @@ func runOutputGuardrails(ctx context.Context, agent *Agent, message llm.Message)
|
||||
// the provided ResumeInput, then re-enters the agent loop. Input guardrails
|
||||
// are not re-evaluated because the messages were already validated in the
|
||||
// original Run call.
|
||||
func Resume(ctx context.Context, interrupted *InterruptedError, input ResumeInput) (*Result, error) {
|
||||
return ResumeWithOpts(ctx, interrupted, input)
|
||||
}
|
||||
|
||||
func ResumeWithOpts(ctx context.Context, interrupted *InterruptedError, input ResumeInput, opts ...RunOption) (*Result, error) {
|
||||
func Resume(ctx context.Context, interrupted *InterruptedError, input ResumeInput, opts ...RunOption) (*Result, error) {
|
||||
ro := runOpts{
|
||||
callLLM: blockingCallLLM,
|
||||
onEvent: noopEvent,
|
||||
|
||||
@@ -59,11 +59,7 @@ func (sr *StreamedRun) Wait() (*Result, error) {
|
||||
return sr.result, sr.err
|
||||
}
|
||||
|
||||
func (a *Agent) RunStreamed(ctx context.Context, messages []llm.Message) *StreamedRun {
|
||||
return a.RunStreamedWithOpts(ctx, messages)
|
||||
}
|
||||
|
||||
func (a *Agent) RunStreamedWithOpts(ctx context.Context, messages []llm.Message, opts ...RunOption) *StreamedRun {
|
||||
func (a *Agent) RunStreamed(ctx context.Context, messages []llm.Message, opts ...RunOption) *StreamedRun {
|
||||
events := make(chan StreamEvent, 64)
|
||||
sr := &StreamedRun{
|
||||
Events: events,
|
||||
|
||||
@@ -228,7 +228,7 @@ func (h *agentRunHandler) executeRun(ctx context.Context, run *coredata.AgentRun
|
||||
if err := json.Unmarshal(run.InputMessages, &inputMsgs); err != nil {
|
||||
runErr = fmt.Errorf("cannot unmarshal input messages: %w", err)
|
||||
} else {
|
||||
result, runErr = a.RunWithOpts(
|
||||
result, runErr = a.Run(
|
||||
ctx,
|
||||
inputMsgs,
|
||||
agent.WithCheckpointer(h.store, runID),
|
||||
|
||||
Reference in New Issue
Block a user