mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-09-09 19:27:48 +02:00
- Add AgentExecutor implementing LLM-based agentic loop with tool calling, max iterations, and stop conditions - Introduce agent preset tools (bash, file_exists, http_get, run_module, etc.) with extensible registry pattern - Add sub-agent spawning capability via spawn_agent tool call with recursive depth limits and validation - Implement ToolExecutor for custom tool execution with template rendering and error handling - Add agent session persistence and memory management with sliding window configuration - Create comprehensive E2E test suite covering 15+ agent workflow scenarios (minimal, custom tools, planning, multi-goal, structured output, tracing hooks, file tools, orchestration, Python tools, sub-agents, nested sub-agents, and validation) - Add agent-and-llm test data directory with 17 YAML workflow fixtures - Update integration tests to include agent workflow directories - Add AgentTool and AgentConfig types with validation for duplicate names and unknown presets - Implement LLM streaming test utilities - Update documentation (CLAUDE.md, HACKING.md, README.md) with agent features and CLI examples
122 lines
2.4 KiB
Go
122 lines
2.4 KiB
Go
package core
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/goccy/go-yaml"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPreferences_GetEmptyTarget(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
prefs *Preferences
|
|
defaultVal bool
|
|
want bool
|
|
}{
|
|
{
|
|
name: "nil preferences returns default true",
|
|
prefs: nil,
|
|
defaultVal: true,
|
|
want: true,
|
|
},
|
|
{
|
|
name: "nil preferences returns default false",
|
|
prefs: nil,
|
|
defaultVal: false,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "nil EmptyTarget returns default true",
|
|
prefs: &Preferences{},
|
|
defaultVal: true,
|
|
want: true,
|
|
},
|
|
{
|
|
name: "nil EmptyTarget returns default false",
|
|
prefs: &Preferences{},
|
|
defaultVal: false,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "EmptyTarget true returns true regardless of default",
|
|
prefs: &Preferences{EmptyTarget: boolPtr(true)},
|
|
defaultVal: false,
|
|
want: true,
|
|
},
|
|
{
|
|
name: "EmptyTarget false returns false regardless of default",
|
|
prefs: &Preferences{EmptyTarget: boolPtr(false)},
|
|
defaultVal: true,
|
|
want: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := tt.prefs.GetEmptyTarget(tt.defaultVal)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestPreferences_UnmarshalYAML_EmptyTarget(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input string
|
|
wantNil bool
|
|
wantVal bool
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "empty_target true",
|
|
input: "empty_target: true",
|
|
wantNil: false,
|
|
wantVal: true,
|
|
},
|
|
{
|
|
name: "empty_target false",
|
|
input: "empty_target: false",
|
|
wantNil: false,
|
|
wantVal: false,
|
|
},
|
|
{
|
|
name: "empty_target not set",
|
|
input: "silent: true",
|
|
wantNil: true,
|
|
},
|
|
{
|
|
name: "empty preferences",
|
|
input: "{}",
|
|
wantNil: true,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
var prefs Preferences
|
|
err := yaml.Unmarshal([]byte(tt.input), &prefs)
|
|
|
|
if tt.wantErr {
|
|
require.Error(t, err)
|
|
return
|
|
}
|
|
|
|
require.NoError(t, err)
|
|
|
|
if tt.wantNil {
|
|
assert.Nil(t, prefs.EmptyTarget)
|
|
} else {
|
|
require.NotNil(t, prefs.EmptyTarget)
|
|
assert.Equal(t, tt.wantVal, *prefs.EmptyTarget)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// boolPtr is a helper to create *bool for tests
|
|
func boolPtr(b bool) *bool {
|
|
return &b
|
|
}
|