mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-17 13:40:53 +08:00
Resume errors from a corrupt or unreadable transcript are returned as "restore Norma session %q: %w" before any model or tool call instead of being dropped; a missing transcript still starts a fresh session. The session id is set and put on the context regardless of the transcript store, so the provider and usage metering see the same identity.
20 lines
626 B
Go
20 lines
626 B
Go
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Autumn-27/norma/agentcore"
|
|
)
|
|
|
|
// resumeSession reloads the persisted conversation of session id into s. Norma's
|
|
// transcript.Store.Load treats a missing file as a fresh session (no records, no
|
|
// error); any other failure, such as a corrupt line or an unreadable path, is
|
|
// returned so the caller stops before the first model or tool call instead of
|
|
// appending a new conversation to the damaged file.
|
|
func resumeSession(s *agentcore.Session, id string) error {
|
|
if err := s.Resume(id); err != nil {
|
|
return fmt.Errorf("restore Norma session %q: %w", id, err)
|
|
}
|
|
return nil
|
|
}
|