Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include proper input on call events #811

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,16 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s
}
}

var content string
if state.ResumeInput != nil {
content = *state.ResumeInput
}
monitor.Event(Event{
Time: time.Now(),
CallContext: callCtx.GetCallContext(),
Type: EventTypeCallContinue,
ToolResults: len(callResults),
Content: content,
})

e := engine.Engine{
Expand Down
5 changes: 1 addition & 4 deletions pkg/sdkserver/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (s SessionFactory) Start(ctx context.Context, prg *types.Program, env []str
Time: time.Now(),
Type: runner.EventTypeRunStart,
},
Input: input,
RunID: id,
Program: prg,
},
Expand All @@ -43,7 +44,6 @@ func (s SessionFactory) Start(ctx context.Context, prg *types.Program, env []str
id: id,
prj: prg,
env: env,
input: input,
events: s.events,
}, nil
}
Expand All @@ -56,7 +56,6 @@ type Session struct {
id string
prj *types.Program
env []string
input string
events *broadcaster.Broadcaster[event]
runLock sync.Mutex
}
Expand All @@ -68,7 +67,6 @@ func (s *Session) Event(e runner.Event) {
Event: gserver.Event{
Event: e,
RunID: s.id,
Input: s.input,
},
}
}
Expand All @@ -87,7 +85,6 @@ func (s *Session) Stop(ctx context.Context, output string, err error) {
Type: runner.EventTypeRunFinish,
},
RunID: s.id,
Input: s.input,
Output: output,
},
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/sdkserver/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (r *runInfo) process(e event) map[string]any {
r.Start = e.Time
r.Program = *e.Program
r.State = Running
r.Input = e.Input
case runner.EventTypeRunFinish:
r.End = e.Time
r.Output = e.Output
Expand All @@ -167,9 +168,11 @@ func (r *runInfo) process(e event) map[string]any {
call.Type = e.Type

switch e.Type {
case runner.EventTypeCallStart:
case runner.EventTypeCallStart, runner.EventTypeCallContinue:
call.Start = e.Time
call.Input = e.Content
if e.Content != "" {
call.Input = e.Content
}

case runner.EventTypeCallSubCalls:
call.setSubCalls(e.ToolSubCalls)
Expand Down