Skip to content

Commit d882cb7

Browse files
bug: fix panic when calling nested chat tool without --force-chat
1 parent eb9e7f5 commit d882cb7

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

pkg/runner/runner.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,6 @@ func (r *Runner) Close() {
9797
r.ports.CloseDaemons()
9898
}
9999

100-
type ErrContinuation struct {
101-
State *State
102-
}
103-
104-
func (e *ErrContinuation) Prompt() string {
105-
return *e.State.Continuation.Result
106-
}
107-
108-
func (e *ErrContinuation) Error() string {
109-
return fmt.Sprintf("chat continuation required: %s", e.Prompt())
110-
}
111-
112100
type ChatResponse struct {
113101
Done bool `json:"done"`
114102
Content string `json:"content"`
@@ -188,25 +176,11 @@ func (r *Runner) Chat(ctx context.Context, prevState ChatState, prg types.Progra
188176
}
189177

190178
func (r *Runner) Run(ctx context.Context, prg types.Program, env []string, input string) (output string, err error) {
191-
monitor, err := r.factory.Start(ctx, &prg, env, input)
192-
if err != nil {
193-
return "", err
194-
}
195-
defer func() {
196-
monitor.Stop(output, err)
197-
}()
198-
199-
callCtx := engine.NewContext(ctx, &prg)
200-
state, err := r.call(callCtx, monitor, env, input)
179+
resp, err := r.Chat(ctx, nil, prg, env, input)
201180
if err != nil {
202181
return "", err
203182
}
204-
if state.Continuation != nil {
205-
return "", &ErrContinuation{
206-
State: state,
207-
}
208-
}
209-
return *state.Result, nil
183+
return resp.Content, nil
210184
}
211185

212186
type Event struct {

0 commit comments

Comments
 (0)