fix(agent/agentic): nil-guard PrepSubsystem.Core() in handleComplete
Defensive nil check returns a typed error result when the subsystem is constructed without a runtime, matching the pattern in adjacent handlers. Adds Bad case test. Co-authored-by: Cerberus <noreply@anthropic.com>
This commit is contained in:
parent
1872424cfd
commit
35b327d47e
2 changed files with 16 additions and 1 deletions
|
|
@ -193,7 +193,11 @@ func (s *PrepSubsystem) handlePersona(_ context.Context, options core.Options) c
|
|||
//
|
||||
// ))
|
||||
func (s *PrepSubsystem) handleComplete(ctx context.Context, options core.Options) core.Result {
|
||||
return s.Core().Task("agent.completion").Run(ctx, s.Core(), options)
|
||||
c := s.Core()
|
||||
if c == nil {
|
||||
return core.Result{Value: core.E("agentic.complete", "core runtime is required", nil), OK: false}
|
||||
}
|
||||
return c.Task("agent.completion").Run(ctx, c, options)
|
||||
}
|
||||
|
||||
// input := agentic.CompleteInput{Workspace: "/srv/.core/workspace/core/go-io/task-42"}
|
||||
|
|
|
|||
|
|
@ -201,6 +201,17 @@ func TestActions_HandleIngest_Bad_NoWorkspace(t *testing.T) {
|
|||
assert.False(t, r.OK)
|
||||
}
|
||||
|
||||
func TestActions_HandleComplete_Bad_NoCore(t *testing.T) {
|
||||
s := &PrepSubsystem{}
|
||||
|
||||
r := s.handleComplete(context.Background(), core.NewOptions())
|
||||
|
||||
assert.False(t, r.OK)
|
||||
err, ok := r.Value.(error)
|
||||
require.True(t, ok)
|
||||
assert.Contains(t, err.Error(), "core runtime is required")
|
||||
}
|
||||
|
||||
func TestActions_HandleWorkspaceQuery_Good(t *testing.T) {
|
||||
s := newPrepWithProcess()
|
||||
s.workspaces = core.NewRegistry[*WorkspaceStatus]()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue