fix test
This commit is contained in:
parent
8e7dd60a8b
commit
331edc332d
|
|
@ -729,14 +729,14 @@ func (s *agent) Inject(prompt string) {
|
||||||
s.fifo.Push(prompt)
|
s.fifo.Push(prompt)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
emit(s.cfg, Event{Role: "info", Content: "\n"})
|
s.emit(Event{Role: "info", Content: "\n"})
|
||||||
emit(s.cfg, Event{Role: "user", Content: prompt})
|
s.emit(Event{Role: "user", Content: prompt})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *agent) injectRewrite(prompt string) {
|
func (s *agent) injectRewrite(prompt string) {
|
||||||
s.pendingInject.Store(&prompt)
|
s.pendingInject.Store(&prompt)
|
||||||
emit(s.cfg, Event{Role: "info", Content: "\n"})
|
s.emit(Event{Role: "info", Content: "\n"})
|
||||||
emit(s.cfg, Event{Role: "user", Content: prompt})
|
s.emit(Event{Role: "user", Content: prompt})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *agent) Queue(prompt string) {
|
func (s *agent) Queue(prompt string) {
|
||||||
|
|
@ -1074,7 +1074,7 @@ func (s *agent) executeTurn(ctx context.Context, input string) string {
|
||||||
if limit <= 0 || s.session.estimateTokens() < limit {
|
if limit <= 0 || s.session.estimateTokens() < limit {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
emit(s.cfg, Event{Role: "info", Content: "auto-compacting context...\n"})
|
s.emit(Event{Role: "info", Content: "auto-compacting context...\n"})
|
||||||
s.setState("compacting")
|
s.setState("compacting")
|
||||||
if _, err := s.runCompact(ctx, "auto"); err != nil {
|
if _, err := s.runCompact(ctx, "auto"); err != nil {
|
||||||
panic(fmt.Sprintf("mid-turn auto-compact: %v", err))
|
panic(fmt.Sprintf("mid-turn auto-compact: %v", err))
|
||||||
|
|
@ -1086,7 +1086,7 @@ func (s *agent) executeTurn(ctx context.Context, input string) string {
|
||||||
if s.session != nil {
|
if s.session != nil {
|
||||||
tokens := s.session.estimateTokens()
|
tokens := s.session.estimateTokens()
|
||||||
if compactLimit := s.autoCompactLimit(ctx); compactLimit > 0 && tokens >= compactLimit {
|
if compactLimit := s.autoCompactLimit(ctx); compactLimit > 0 && tokens >= compactLimit {
|
||||||
emit(s.cfg, Event{Role: "info", Content: "auto-compacting context...\n"})
|
s.emit(Event{Role: "info", Content: "auto-compacting context...\n"})
|
||||||
s.setState("compacting")
|
s.setState("compacting")
|
||||||
if _, err := s.runCompact(ctx, "auto"); err != nil {
|
if _, err := s.runCompact(ctx, "auto"); err != nil {
|
||||||
panic(fmt.Sprintf("auto-compact: %v", err))
|
panic(fmt.Sprintf("auto-compact: %v", err))
|
||||||
|
|
@ -1098,7 +1098,7 @@ func (s *agent) executeTurn(ctx context.Context, input string) string {
|
||||||
ctxLen = defaultContextLength
|
ctxLen = defaultContextLength
|
||||||
}
|
}
|
||||||
pct := tokens * 100 / ctxLen
|
pct := tokens * 100 / ctxLen
|
||||||
emit(s.cfg, Event{Role: "info", Content: fmt.Sprintf("context at %d%% — will auto-compact at 75%%\n", pct)})
|
s.emit(Event{Role: "info", Content: fmt.Sprintf("context at %d%% — will auto-compact at 75%%\n", pct)})
|
||||||
s.warnedContext = true
|
s.warnedContext = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1145,7 +1145,7 @@ func (s *agent) executeTurn(ctx context.Context, input string) string {
|
||||||
if !overflowRetried && errors.As(err, &ctxErr) && s.session != nil {
|
if !overflowRetried && errors.As(err, &ctxErr) && s.session != nil {
|
||||||
overflowRetried = true
|
overflowRetried = true
|
||||||
s.session.messages = snapMessages
|
s.session.messages = snapMessages
|
||||||
emit(s.cfg, Event{Role: "info", Content: "context overflow — compacting and retrying...\n"})
|
s.emit(Event{Role: "info", Content: "context overflow — compacting and retrying...\n"})
|
||||||
s.setState("compacting")
|
s.setState("compacting")
|
||||||
if _, cerr := s.runCompact(ctx, "overflow"); cerr != nil {
|
if _, cerr := s.runCompact(ctx, "overflow"); cerr != nil {
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Reference in New Issue