Skip to content

Commit

Permalink
Merge pull request #811 from thedadams/include-input-call-events
Browse files Browse the repository at this point in the history
fix: include proper input on call events
  • Loading branch information
thedadams authored Aug 21, 2024
2 parents a7c8e57 + 1202543 commit f8f81a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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

0 comments on commit f8f81a5

Please sign in to comment.