agent: drop error return from Session.update
The function only appends to a slice and can never fail. Removing the dead error return eliminates the nolint:errcheck suppression on the interrupted-stream path in loop.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
18b5c2c08c
commit
132174df95
|
|
@ -110,7 +110,7 @@ func run(ctx context.Context, cfg agentConfig, state state) error {
|
|||
IsError: true,
|
||||
})
|
||||
}
|
||||
state.update(msg, results) //nolint:errcheck
|
||||
state.update(msg, results)
|
||||
return fmt.Errorf("step %d: stream interrupted: %w", step, ctx.Err())
|
||||
}
|
||||
|
||||
|
|
@ -235,9 +235,7 @@ func run(ctx context.Context, cfg agentConfig, state state) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := state.update(msg, results); err != nil {
|
||||
return fmt.Errorf("step %d update: %w", step, err)
|
||||
}
|
||||
state.update(msg, results)
|
||||
|
||||
if interrupted {
|
||||
return ctx.Err()
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func (s *Session) addUsage(u backend.Usage, estimated bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *Session) update(assistant backend.Message, results []toolResult) error {
|
||||
func (s *Session) update(assistant backend.Message, results []toolResult) {
|
||||
s.messages = append(s.messages, assistant)
|
||||
for _, r := range results {
|
||||
s.messages = append(s.messages, backend.Message{
|
||||
|
|
@ -103,7 +103,6 @@ func (s *Session) update(assistant backend.Message, results []toolResult) error
|
|||
ToolCallID: r.ToolCallID,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PreCompactionSnapshot returns a copy of the current messages for persistence
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ type state interface {
|
|||
|
||||
// Update appends the assistant's reply and any tool results to the history.
|
||||
// Called once per loop iteration after Act completes.
|
||||
update(assistant backend.Message, results []toolResult) error
|
||||
update(assistant backend.Message, results []toolResult)
|
||||
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue