Drop Felix references; harness stands as a platform on its own
Removes every Felix mention from public-facing surfaces so the framework reads as a standalone agent platform rather than an extracted module. User-visible changes: - HTTP User-Agent on web_fetch / web_search: Felix/1.0 → harness/1.0 - bash tool path-substitution prefix: '[felix]' → '[harness]' - On-disk paths: <workspace>/.felix/ → <workspace>/.harness/ (todos.json + spill/ tree); tests updated in lockstep. - OTel trace attributes: felix.trace_id / felix.total_ms / felix.phase_count → harness.* equivalents. Doc-comment changes: - Examples (lta-agent, data-agent) lose 'non-Felix consumer' framing. - README drops the 'extracted from Felix' lede and the 'What was lifted from Felix' section, replaced with a 'Design' overview that points to developer.md. - Runtime / tool / compaction doc comments rewritten so behaviour notes describe what the harness does without naming the prior origin. - Test-fixture text 'you are felix' → 'you are an assistant'. Verified: zero 'felix' (case-insensitive) in tracked .go / .md files. All 16 packages build and pass tests.
This commit is contained in:
1 parent
8ed38d7b66
commit
123a233cb7
22 files changed
+107
-85
No files matched your search
@@ -1,9 +1,9 @@
|
|||||||
# harness
|
# harness
|
||||||
|
|
||||||
A reusable Go agentic harness extracted from [Felix](https://github.com/sausheong/felix).
|
A reusable Go agentic platform for building LLM agents. Implements the
|
||||||
Implements the streaming agent loop, tool registry, session storage, compaction, and
|
streaming agent loop, tool registry, session storage, compaction, and
|
||||||
token budgeting that drive a multi-provider LLM agent. BYO concrete tools, BYO
|
token budgeting needed to run a multi-provider agent in production. BYO
|
||||||
provider clients, BYO memory/knowledge-graph plugins.
|
concrete tools, BYO provider clients, BYO memory/knowledge-graph plugins.
|
||||||
|
|
||||||
## Packages
|
## Packages
|
||||||
|
|
||||||
@@ -74,13 +74,25 @@ func main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## What was lifted from Felix
|
## Design
|
||||||
|
|
||||||
This module is a structural extraction of `internal/{agent,llm,tools,session,compaction,tokens}`.
|
The harness is intentionally minimal. Every agent gets:
|
||||||
Behavior is preserved verbatim — same partition algorithm, same compaction triggers,
|
|
||||||
same prompt cache stability rules, same token calibrator. Felix-specific pieces
|
- A streaming think-act loop with parallel tool dispatch
|
||||||
(HTTP gateway, JSON5 config, MCP client, bundled Ollama, knowledge-graph adapter,
|
- A pluggable LLM provider interface (Anthropic, OpenAI, Gemini, Qwen
|
||||||
markdown skill loader, Telegram outbound, file-backed memory) stay in Felix.
|
built in; bring your own to add more)
|
||||||
|
- Append-only session storage with optional JSONL persistence
|
||||||
|
- Three-stage summarize-and-splice compaction with prompt-cache-stable
|
||||||
|
prefixes
|
||||||
|
- A token budget calibrator that learns the chars→tokens ratio per
|
||||||
|
session
|
||||||
|
|
||||||
|
Everything else — skills, long-term memory, knowledge graphs,
|
||||||
|
permission policies, subagent dispatch, on-disk session stores — is an
|
||||||
|
optional plug-point. Pass `nil` and it disappears.
|
||||||
|
|
||||||
|
See [`developer.md`](./developer.md) for a step-by-step guide to
|
||||||
|
building agents on top of harness.
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ func transcriptDelimiterSuffix() string {
|
|||||||
// - Section 6 ("All user messages") is the load-bearing anti-drift
|
// - Section 6 ("All user messages") is the load-bearing anti-drift
|
||||||
// mechanism. Without it, summarizers collapse multiple distinct user
|
// mechanism. Without it, summarizers collapse multiple distinct user
|
||||||
// asks into a single sentence keyed off whichever topic came first,
|
// asks into a single sentence keyed off whichever topic came first,
|
||||||
// which causes the next turn to misframe the conversation (Felix bug
|
// which causes the next turn to misframe the conversation — the
|
||||||
// post-mortem: model said "previous conversation covered Colima" when
|
// resumed model says "previous conversation covered X" when the
|
||||||
// the most recent topic was Wasm/Extism).
|
// most recent topic was actually Y.
|
||||||
// - Section 9 ("Optional Next Step") demands verbatim quotes from the
|
// - Section 9 ("Optional Next Step") demands verbatim quotes from the
|
||||||
// most recent messages so the resumed turn doesn't drift on task
|
// most recent messages so the resumed turn doesn't drift on task
|
||||||
// interpretation.
|
// interpretation.
|
||||||
|
|||||||
@@ -13,9 +13,10 @@ import "github.com/sausheong/harness/session"
|
|||||||
// that preserves K turns. Caller should refuse to compact rather than over-
|
// that preserves K turns. Caller should refuse to compact rather than over-
|
||||||
// compacting.
|
// compacting.
|
||||||
//
|
//
|
||||||
// A user message is always a clean boundary by construction in Felix's
|
// A user message is always a clean boundary by construction in the
|
||||||
// runtime (user msg → assistant text → tool_call → tool_result → next user
|
// harness runtime (user msg → assistant text → tool_call → tool_result
|
||||||
// msg). Splitting before a user message therefore never orphans a tool pair.
|
// → next user msg). Splitting before a user message therefore never
|
||||||
|
// orphans a tool pair.
|
||||||
func Split(history []session.SessionEntry, K int) (toCompact, toPreserve []session.SessionEntry, ok bool) {
|
func Split(history []session.SessionEntry, K int) (toCompact, toPreserve []session.SessionEntry, ok bool) {
|
||||||
if K <= 0 || len(history) == 0 {
|
if K <= 0 || len(history) == 0 {
|
||||||
return nil, nil, false
|
return nil, nil, false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// data.gov.sg agent — a second non-Felix consumer of the harness framework
|
// data.gov.sg agent — example agent built on harness that talks to
|
||||||
// that talks to Singapore's open-data APIs (real-time environment + CKAN
|
// Singapore's open-data APIs (real-time environment + CKAN dataset
|
||||||
// dataset catalog).
|
// catalog).
|
||||||
//
|
//
|
||||||
// Composition surface used (identical to lta-agent):
|
// Composition surface used (identical to lta-agent):
|
||||||
// - tool.Registry (BYO concrete tools — none from harness/tools/*)
|
// - tool.Registry (BYO concrete tools — none from harness/tools/*)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// LTA Datamall agent — a non-Felix consumer of the harness framework
|
// LTA Datamall agent — example of building a domain-specific agent on
|
||||||
// that proves the API isn't accidentally Felix-shaped.
|
// the harness framework with custom tools (no harness/tools/* deps).
|
||||||
//
|
//
|
||||||
// Composition surface used:
|
// Composition surface used:
|
||||||
// - tool.Registry (BYO concrete tools — none from harness/tools/*)
|
// - tool.Registry (BYO concrete tools — none from harness/tools/*)
|
||||||
@@ -9,9 +9,8 @@
|
|||||||
// - runtime.Run streaming loop
|
// - runtime.Run streaming loop
|
||||||
//
|
//
|
||||||
// Deliberately NOT used:
|
// Deliberately NOT used:
|
||||||
// - Skills, Memory, KnowledgeGraph (consumer doesn't need them)
|
// - Skills, Memory, KnowledgeGraph (this agent doesn't need them)
|
||||||
// - Subagents, compaction, calibrator persistence
|
// - Subagents, compaction, calibrator persistence
|
||||||
// - Any Felix-specific config or path conventions
|
|
||||||
//
|
//
|
||||||
// Run:
|
// Run:
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ func TestBuildMessageParamsIsPure(t *testing.T) {
|
|||||||
MaxTokens: 4096,
|
MaxTokens: 4096,
|
||||||
Temperature: 0.7,
|
Temperature: 0.7,
|
||||||
SystemPromptParts: []llm.SystemPromptPart{
|
SystemPromptParts: []llm.SystemPromptPart{
|
||||||
{Text: "you are felix", Cache: true},
|
{Text: "you are an assistant", Cache: true},
|
||||||
{Text: "today is 2026-05-01"},
|
{Text: "today is 2026-05-01"},
|
||||||
},
|
},
|
||||||
Messages: []llm.Message{
|
Messages: []llm.Message{
|
||||||
|
|||||||
@@ -44,9 +44,10 @@ func TestBuildStaticSystemPromptIdentity(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Consumers wanting "configuration file is at ..." in the static prompt
|
// Consumers wanting "configuration file is at ..." in the static prompt
|
||||||
// pass it through deps.ConfigSummary; the harness no longer hard-codes
|
// pass it through deps.ConfigSummary; the harness does not hard-code
|
||||||
// Felix's config path. Verify the agent identity + IDENTITY.md content
|
// any config path of its own. Verify the agent identity + IDENTITY.md
|
||||||
// land verbatim, plus that a caller-supplied config summary is honoured.
|
// content land verbatim, plus that a caller-supplied config summary
|
||||||
|
// is honoured.
|
||||||
result := BuildStaticSystemPrompt(dir, "", "test", "Test Agent",
|
result := BuildStaticSystemPrompt(dir, "", "test", "Test Agent",
|
||||||
[]string{"read_file", "bash"}, "configuration file is at /tmp/x.json", "", "", "")
|
[]string{"read_file", "bash"}, "configuration file is at /tmp/x.json", "", "", "")
|
||||||
assert.Contains(t, result, identityContent)
|
assert.Contains(t, result, identityContent)
|
||||||
@@ -308,7 +309,7 @@ func TestPruneToolResultsSpillsToDisk(t *testing.T) {
|
|||||||
// Spill file lives where the marker text says it does, holds the
|
// Spill file lives where the marker text says it does, holds the
|
||||||
// full original content, and the path embedded in the message is
|
// full original content, and the path embedded in the message is
|
||||||
// absolute (so read_file's path handling works regardless of CWD).
|
// absolute (so read_file's path handling works regardless of CWD).
|
||||||
wantPath := filepath.Join(workspace, ".felix", "spill", "sess_abc", "tc_42.txt")
|
wantPath := filepath.Join(workspace, ".harness", "spill", "sess_abc", "tc_42.txt")
|
||||||
assert.Contains(t, got, wantPath)
|
assert.Contains(t, got, wantPath)
|
||||||
assert.True(t, filepath.IsAbs(wantPath))
|
assert.True(t, filepath.IsAbs(wantPath))
|
||||||
data, err := os.ReadFile(wantPath)
|
data, err := os.ReadFile(wantPath)
|
||||||
|
|||||||
+6
-4
@@ -25,8 +25,9 @@ type RuntimeDeps struct {
|
|||||||
// KGFn returns the per-agent KnowledgeGraph for the given model
|
// KGFn returns the per-agent KnowledgeGraph for the given model
|
||||||
// string. Nil at the call site means KG is disabled for this Runtime.
|
// string. Nil at the call site means KG is disabled for this Runtime.
|
||||||
// The function shape (rather than a single KG) lets consumers route
|
// The function shape (rather than a single KG) lets consumers route
|
||||||
// the chatting agent's own model to the KG's underlying LLM (Felix
|
// the chatting agent's own model to the KG's underlying LLM — useful
|
||||||
// uses this to mirror the chat model into Cortex's extractor).
|
// when the KG runs an extractor on the same provider/model as the
|
||||||
|
// agent itself.
|
||||||
KGFn func(model string) KnowledgeGraph
|
KGFn func(model string) KnowledgeGraph
|
||||||
// AgentLoop carries the loop tunables (concurrency cap, depth cap,
|
// AgentLoop carries the loop tunables (concurrency cap, depth cap,
|
||||||
// streaming-tools toggle). Copied verbatim into every Runtime built
|
// streaming-tools toggle). Copied verbatim into every Runtime built
|
||||||
@@ -42,8 +43,9 @@ type RuntimeDeps struct {
|
|||||||
// changes only on hot-reload.
|
// changes only on hot-reload.
|
||||||
ConfigSummary string
|
ConfigSummary string
|
||||||
// MemoryFiles, when non-empty, is appended to the static system
|
// MemoryFiles, when non-empty, is appended to the static system
|
||||||
// prompt. Consumers compose this themselves (Felix walks
|
// prompt. Consumers compose this themselves — typical pattern is to
|
||||||
// FELIX.md / AGENTS.md from workspace + $HOME).
|
// concatenate AGENTS.md (and any project-specific identity files)
|
||||||
|
// from the workspace and the user's $HOME.
|
||||||
MemoryFiles string
|
MemoryFiles string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ func TestBuildRuntimeMinimalSpecSafe(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildRuntimeUsesCallerProvidedMemoryFiles(t *testing.T) {
|
func TestBuildRuntimeUsesCallerProvidedMemoryFiles(t *testing.T) {
|
||||||
// Caller composes memoryFiles however they want (Felix walks
|
// Caller composes memoryFiles however they want — typical patterns
|
||||||
// FELIX.md/AGENTS.md from workspace + $HOME; other consumers may
|
// include walking AGENTS.md from workspace + $HOME, building from a
|
||||||
// build it from a wiki dump, a doc index, etc.). Harness only
|
// wiki dump, or pulling from a doc index. Harness only concatenates
|
||||||
// concatenates it into the static prompt.
|
// it into the static prompt.
|
||||||
const sentinel = "MEMFILE_END_TO_END_SENTINEL"
|
const sentinel = "MEMFILE_END_TO_END_SENTINEL"
|
||||||
deps := RuntimeDeps{
|
deps := RuntimeDeps{
|
||||||
MemoryFiles: "\n\n## Project memory: AGENTS.md\n\n" + sentinel,
|
MemoryFiles: "\n\n## Project memory: AGENTS.md\n\n" + sentinel,
|
||||||
|
|||||||
+9
-7
@@ -86,12 +86,14 @@ func buildDefaultIdentity(toolNames []string) string {
|
|||||||
// per-turn. Suitable to call once at Runtime construction.
|
// per-turn. Suitable to call once at Runtime construction.
|
||||||
//
|
//
|
||||||
// configSummary is the consumer's place to advertise things like the
|
// configSummary is the consumer's place to advertise things like the
|
||||||
// configured agents, channel bindings, configuration paths, or any other
|
// configured agents, channel bindings, configuration paths, or any
|
||||||
// hot-reload-bound context. Felix uses it to inject a list of configured
|
// other hot-reload-bound context. Leave empty if you have nothing to
|
||||||
// agents and the path to felix.json5; other consumers can leave it empty.
|
// surface.
|
||||||
//
|
//
|
||||||
// memoryFiles is the consumer's place to inject project / user memory
|
// memoryFiles is the consumer's place to inject project / user memory
|
||||||
// files (e.g., Felix walks FELIX.md and AGENTS.md from workspace + $HOME).
|
// files. A common pattern is to concatenate AGENTS.md from the
|
||||||
|
// workspace and the user's $HOME, but the harness only treats this as
|
||||||
|
// opaque text to append.
|
||||||
func BuildStaticSystemPrompt(
|
func BuildStaticSystemPrompt(
|
||||||
workspace, systemPrompt, agentID, agentName string,
|
workspace, systemPrompt, agentID, agentName string,
|
||||||
toolNames []string,
|
toolNames []string,
|
||||||
@@ -404,7 +406,7 @@ const (
|
|||||||
// without a workspace working unchanged.
|
// without a workspace working unchanged.
|
||||||
//
|
//
|
||||||
// When Workspace is set, oversized tool results are written to
|
// When Workspace is set, oversized tool results are written to
|
||||||
// <Workspace>/.felix/spill/<SessionKey>/<ToolCallID>.txt and the message
|
// <Workspace>/.harness/spill/<SessionKey>/<ToolCallID>.txt and the message
|
||||||
// is rewritten as: head preview (first maxLen chars cut at newline) +
|
// is rewritten as: head preview (first maxLen chars cut at newline) +
|
||||||
// spillMarker pointing the model at the absolute path so it can recover
|
// spillMarker pointing the model at the absolute path so it can recover
|
||||||
// the full output via read_file (which gates on Workspace).
|
// the full output via read_file (which gates on Workspace).
|
||||||
@@ -421,7 +423,7 @@ func spillToolResult(cfg spillConfig, toolCallID, content string) (string, error
|
|||||||
if cfg.Workspace == "" || cfg.SessionKey == "" || toolCallID == "" {
|
if cfg.Workspace == "" || cfg.SessionKey == "" || toolCallID == "" {
|
||||||
return "", fmt.Errorf("spillToolResult: workspace, session key, and tool call id are required")
|
return "", fmt.Errorf("spillToolResult: workspace, session key, and tool call id are required")
|
||||||
}
|
}
|
||||||
dir := filepath.Join(cfg.Workspace, ".felix", "spill", cfg.SessionKey)
|
dir := filepath.Join(cfg.Workspace, ".harness", "spill", cfg.SessionKey)
|
||||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||||
return "", fmt.Errorf("spill mkdir: %w", err)
|
return "", fmt.Errorf("spill mkdir: %w", err)
|
||||||
}
|
}
|
||||||
@@ -440,7 +442,7 @@ func spillToolResult(cfg spillConfig, toolCallID, content string) (string, error
|
|||||||
//
|
//
|
||||||
// Two modes:
|
// Two modes:
|
||||||
// - With cfg.Workspace + cfg.SessionKey set: the FULL original content
|
// - With cfg.Workspace + cfg.SessionKey set: the FULL original content
|
||||||
// is written to <Workspace>/.felix/spill/<SessionKey>/<ToolCallID>.txt
|
// is written to <Workspace>/.harness/spill/<SessionKey>/<ToolCallID>.txt
|
||||||
// and the message becomes "<head>\n\n[spilled — N of M chars saved
|
// and the message becomes "<head>\n\n[spilled — N of M chars saved
|
||||||
// to <abs path>; use read_file to access the full output]". The
|
// to <abs path>; use read_file to access the full output]". The
|
||||||
// model can recover the entire output via read_file, eliminating the
|
// model can recover the entire output via read_file, eliminating the
|
||||||
|
|||||||
+4
-4
@@ -14,12 +14,12 @@ import (
|
|||||||
//
|
//
|
||||||
// Mirrors the path layout used by spillToolResult in context.go:
|
// Mirrors the path layout used by spillToolResult in context.go:
|
||||||
//
|
//
|
||||||
// <workspace>/.felix/spill/<sessionKey>/
|
// <workspace>/.harness/spill/<sessionKey>/
|
||||||
func SpillDirForSession(workspace, sessionKey string) string {
|
func SpillDirForSession(workspace, sessionKey string) string {
|
||||||
if workspace == "" || sessionKey == "" {
|
if workspace == "" || sessionKey == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return filepath.Join(workspace, ".felix", "spill", sessionKey)
|
return filepath.Join(workspace, ".harness", "spill", sessionKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveSessionSpill removes the per-session spill directory if it exists.
|
// RemoveSessionSpill removes the per-session spill directory if it exists.
|
||||||
@@ -42,7 +42,7 @@ func SpillRoot(workspace string) string {
|
|||||||
if workspace == "" {
|
if workspace == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return filepath.Join(workspace, ".felix", "spill")
|
return filepath.Join(workspace, ".harness", "spill")
|
||||||
}
|
}
|
||||||
|
|
||||||
// LiveSessionKeysFn returns the set of currently-existing session keys for
|
// LiveSessionKeysFn returns the set of currently-existing session keys for
|
||||||
@@ -51,7 +51,7 @@ func SpillRoot(workspace string) string {
|
|||||||
// session JSONL on disk).
|
// session JSONL on disk).
|
||||||
type LiveSessionKeysFn func() (map[string]bool, error)
|
type LiveSessionKeysFn func() (map[string]bool, error)
|
||||||
|
|
||||||
// CleanupOrphanedSpills walks <workspace>/.felix/spill/ and removes any
|
// CleanupOrphanedSpills walks <workspace>/.harness/spill/ and removes any
|
||||||
// per-session subdirectory whose key is not in the set returned by liveKeys.
|
// per-session subdirectory whose key is not in the set returned by liveKeys.
|
||||||
// Returns the number of directories removed and the first error encountered
|
// Returns the number of directories removed and the first error encountered
|
||||||
// (if any). Missing root is not an error — it just means nothing to clean.
|
// (if any). Missing root is not an error — it just means nothing to clean.
|
||||||
|
|||||||
+2
-2
@@ -36,8 +36,8 @@ type SubagentBuildFn func(spec AgentSpec) (RuntimeInputs, error)
|
|||||||
type SubagentSpec struct {
|
type SubagentSpec struct {
|
||||||
Spec AgentSpec
|
Spec AgentSpec
|
||||||
// Registered reports whether the consumer considers this subagent ID
|
// Registered reports whether the consumer considers this subagent ID
|
||||||
// valid for parent-driven invocation. Mirrors Felix's
|
// valid for parent-driven invocation. False prevents a parent agent
|
||||||
// AgentConfig.Subagent flag.
|
// from spawning this child via the task tool.
|
||||||
Registered bool
|
Registered bool
|
||||||
// InheritContext, when true, copies the parent session's view into
|
// InheritContext, when true, copies the parent session's view into
|
||||||
// the child session before BuildRuntime fires.
|
// the child session before BuildRuntime fires.
|
||||||
|
|||||||
@@ -229,9 +229,9 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestRun_SubagentDepthCapEnforced verifies the cap stops construction past
|
// TestRun_SubagentDepthCapEnforced verifies the cap stops construction past
|
||||||
// the configured limit. With FELIX_MAX_AGENT_DEPTH=2, a parent at depth 0
|
// the configured limit. With MaxAgentDepth=2, a parent at depth 0 can call
|
||||||
// can call a subagent (depth 1), and that subagent can call another (depth 2),
|
// a subagent (depth 1), and that subagent can call another (depth 2), but
|
||||||
// but a third-level attempt (depth 3) must fail with the cap error and the
|
// a third-level attempt (depth 3) must fail with the cap error and the
|
||||||
// would-be subagent's RuntimeInputs builder must NOT be invoked.
|
// would-be subagent's RuntimeInputs builder must NOT be invoked.
|
||||||
//
|
//
|
||||||
// Note: this test reimplements the factory wiring rather than calling
|
// Note: this test reimplements the factory wiring rather than calling
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import (
|
|||||||
"github.com/sausheong/harness/llm"
|
"github.com/sausheong/harness/llm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// testCfg is the harness test analogue of Felix's *config.Config — bundles
|
// testCfg is a tiny stand-in for whatever live-config object a real
|
||||||
// a SubagentResolver with the small accessor helpers (EligibleSubagents,
|
// consumer would hold. It bundles a SubagentResolver with the small
|
||||||
// GetAgent) that subagent tests reach for. Lets the subagent_test.go and
|
// accessor helpers (EligibleSubagents, GetAgent) that subagent tests
|
||||||
// inheritance_test.go call sites keep their `cfg.X()` shape after the
|
// reach for, so subagent_test.go and inheritance_test.go can keep
|
||||||
// extraction without rewriting every test.
|
// their `cfg.X()` call shape.
|
||||||
type testCfg struct {
|
type testCfg struct {
|
||||||
specs map[string]AgentSpec
|
specs map[string]AgentSpec
|
||||||
subagent map[string]bool // id → registered as subagent
|
subagent map[string]bool // id → registered as subagent
|
||||||
@@ -41,7 +41,8 @@ func (c *testCfg) GetAgent(id string) (AgentSpec, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newTwoAgentCfg builds a fixture with a parent ("default") and one
|
// newTwoAgentCfg builds a fixture with a parent ("default") and one
|
||||||
// subagent ("researcher"). Direct port of Felix's twoAgentConfig fixture.
|
// subagent ("researcher") — the minimal shape needed to exercise the
|
||||||
|
// task-tool dispatch path.
|
||||||
func newTwoAgentCfg(t *testing.T) *testCfg {
|
func newTwoAgentCfg(t *testing.T) *testCfg {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
parent := AgentSpec{
|
parent := AgentSpec{
|
||||||
|
|||||||
+3
-3
@@ -96,7 +96,7 @@ func NewTrace(agentID, model string) *Trace {
|
|||||||
if otelTracer != nil {
|
if otelTracer != nil {
|
||||||
_, t.span = otelTracer.Start(context.Background(), "agent.run",
|
_, t.span = otelTracer.Start(context.Background(), "agent.run",
|
||||||
trace.WithAttributes(
|
trace.WithAttributes(
|
||||||
attribute.String("felix.trace_id", id),
|
attribute.String("harness.trace_id", id),
|
||||||
attribute.String("agent.id", agentID),
|
attribute.String("agent.id", agentID),
|
||||||
attribute.String("llm.model", model),
|
attribute.String("llm.model", model),
|
||||||
),
|
),
|
||||||
@@ -219,8 +219,8 @@ func (t *Trace) Summary() {
|
|||||||
|
|
||||||
if t.span != nil {
|
if t.span != nil {
|
||||||
t.span.SetAttributes(
|
t.span.SetAttributes(
|
||||||
attribute.Int64("felix.total_ms", total),
|
attribute.Int64("harness.total_ms", total),
|
||||||
attribute.Int("felix.phase_count", len(t.phases)),
|
attribute.Int("harness.phase_count", len(t.phases)),
|
||||||
)
|
)
|
||||||
t.span.End()
|
t.span.End()
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-12
@@ -5,10 +5,11 @@ import "context"
|
|||||||
// AgentSpec is the framework's view of an agent. Consumers convert their
|
// AgentSpec is the framework's view of an agent. Consumers convert their
|
||||||
// own agent-config types into this struct before invoking BuildRuntime.
|
// own agent-config types into this struct before invoking BuildRuntime.
|
||||||
//
|
//
|
||||||
// Mirrors the fields Runtime actually consumes; Felix-specific options
|
// Holds only the fields Runtime actually consumes. Anything richer that
|
||||||
// (per-agent tool policies, MCP server bindings, channel routing,
|
// a consumer's config carries (per-agent tool policies, MCP server
|
||||||
// inheritContext flag, subagent registration, identity files) live in the
|
// bindings, channel routing, inheritContext flags, subagent
|
||||||
// consumer's config and are resolved before this struct is filled in.
|
// registration, identity files) is resolved by the consumer before this
|
||||||
|
// struct is filled in.
|
||||||
type AgentSpec struct {
|
type AgentSpec struct {
|
||||||
// ID identifies the agent for logging, session paths, and subagent
|
// ID identifies the agent for logging, session paths, and subagent
|
||||||
// resolution. Used as session.Session.AgentID.
|
// resolution. Used as session.Session.AgentID.
|
||||||
@@ -43,11 +44,10 @@ type AgentSpec struct {
|
|||||||
Loop LoopConfig
|
Loop LoopConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoopConfig tunes the agent runtime's tool-execution behavior. Mirrors
|
// LoopConfig tunes the agent runtime's tool-execution behavior. Each
|
||||||
// Felix's AgentLoopConfig with framework-side env-var fallbacks
|
// field has a built-in env-var fallback (HARNESS_MAX_TOOL_CONCURRENCY,
|
||||||
// (HARNESS_MAX_TOOL_CONCURRENCY, HARNESS_MAX_AGENT_DEPTH,
|
// HARNESS_MAX_AGENT_DEPTH, HARNESS_STREAMING_TOOLS); set the field
|
||||||
// HARNESS_STREAMING_TOOLS) — Felix consumers may set the FELIX_* env vars
|
// explicitly from your own config to bypass the env vars.
|
||||||
// instead by setting these fields explicitly from their own config block.
|
|
||||||
type LoopConfig struct {
|
type LoopConfig struct {
|
||||||
// MaxToolConcurrency caps parallel tool dispatch within a safe batch.
|
// MaxToolConcurrency caps parallel tool dispatch within a safe batch.
|
||||||
// 0 ⇒ env fallback then default 10.
|
// 0 ⇒ env fallback then default 10.
|
||||||
@@ -91,7 +91,9 @@ type Message struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// KnowledgeGraph is the optional plug point for a long-term memory /
|
// KnowledgeGraph is the optional plug point for a long-term memory /
|
||||||
// knowledge-graph backend. Felix wires this to its cortex adapter.
|
// knowledge-graph backend. Wire your own implementation if you need
|
||||||
|
// recall + ingest hooks; leave deps.KGFn nil to disable the entire
|
||||||
|
// pathway.
|
||||||
//
|
//
|
||||||
// - ShouldRecall is called synchronously at the start of every Run
|
// - ShouldRecall is called synchronously at the start of every Run
|
||||||
// before scheduling the recall goroutine. Cheap; should return
|
// before scheduling the recall goroutine. Cheap; should return
|
||||||
@@ -121,6 +123,7 @@ type KnowledgeGraph interface {
|
|||||||
// child Runtime. Returning ok=false makes TaskTool surface a "subagent
|
// child Runtime. Returning ok=false makes TaskTool surface a "subagent
|
||||||
// %q not found" error to the parent LLM.
|
// %q not found" error to the parent LLM.
|
||||||
//
|
//
|
||||||
// Implementations typically read from a live config so subagent
|
// Implementations typically read from a live config object (often via
|
||||||
// definitions hot-reload (Felix reads through *config.Config).
|
// an atomic.Value) so subagent definitions hot-reload without
|
||||||
|
// restarting the runtime.
|
||||||
type SubagentResolver func(agentID string) (spec AgentSpec, registered bool, ok bool)
|
type SubagentResolver func(agentID string) (spec AgentSpec, registered bool, ok bool)
|
||||||
+4
-3
@@ -15,8 +15,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ExpandHome rewrites a leading "~" or "~/" in p to the user's home directory.
|
// ExpandHome rewrites a leading "~" or "~/" in p to the user's home directory.
|
||||||
// Other tildes (mid-path, "~user/...") are left alone — Felix never escalates
|
// Other tildes (mid-path, "~user/...") are left alone — the harness never
|
||||||
// privileges, so cross-user tilde expansion would silently fail anyway.
|
// escalates privileges, so cross-user tilde expansion would silently fail
|
||||||
|
// anyway.
|
||||||
//
|
//
|
||||||
// The shell ($BASH/zsh) does this expansion before exec, which is why the
|
// The shell ($BASH/zsh) does this expansion before exec, which is why the
|
||||||
// bash tool works without it. read/write/edit_file call os.Open directly so
|
// bash tool works without it. read/write/edit_file call os.Open directly so
|
||||||
@@ -156,7 +157,7 @@ func SanitizeLLMText(s string) string {
|
|||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tool is the interface that all Felix tools must implement.
|
// Tool is the interface every harness tool must implement.
|
||||||
type Tool interface {
|
type Tool interface {
|
||||||
Name() string
|
Name() string
|
||||||
Description() string
|
Description() string
|
||||||
|
|||||||
+1
-1
@@ -268,7 +268,7 @@ func pathSubsNotice(subs [][2]string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
b.WriteString("[felix] adjusted paths in command (Unicode-whitespace recovery):\n")
|
b.WriteString("[harness] adjusted paths in command (Unicode-whitespace recovery):\n")
|
||||||
for _, s := range subs {
|
for _, s := range subs {
|
||||||
fmt.Fprintf(&b, " %q -> %q\n", s[0], s[1])
|
fmt.Fprintf(&b, " %q -> %q\n", s[0], s[1])
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -32,7 +32,7 @@ type TodoItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TodoWriteTool maintains a per-workspace todo list the agent uses to
|
// TodoWriteTool maintains a per-workspace todo list the agent uses to
|
||||||
// track multi-step work. Persisted to <Workspace>/.felix/todos.json so
|
// track multi-step work. Persisted to <Workspace>/.harness/todos.json so
|
||||||
// it survives across turns within a session and across sessions for
|
// it survives across turns within a session and across sessions for
|
||||||
// the same workspace.
|
// the same workspace.
|
||||||
//
|
//
|
||||||
@@ -175,7 +175,7 @@ func (t *TodoWriteTool) Execute(_ context.Context, input json.RawMessage) (tool.
|
|||||||
return tool.ToolResult{Output: formatTodos(items)}, nil
|
return tool.ToolResult{Output: formatTodos(items)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// load reads the persisted todos from <WorkDir>/.felix/todos.json.
|
// load reads the persisted todos from <WorkDir>/.harness/todos.json.
|
||||||
// Missing file → empty list (not an error). Corrupt JSON → error so
|
// Missing file → empty list (not an error). Corrupt JSON → error so
|
||||||
// the agent knows the file needs manual repair rather than silently
|
// the agent knows the file needs manual repair rather than silently
|
||||||
// dropping work.
|
// dropping work.
|
||||||
@@ -217,7 +217,7 @@ func (t *TodoWriteTool) save(items []TodoItem) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TodoWriteTool) todosPath() string {
|
func (t *TodoWriteTool) todosPath() string {
|
||||||
return filepath.Join(t.WorkDir, ".felix", "todos.json")
|
return filepath.Join(t.WorkDir, ".harness", "todos.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
// nextTodoID returns the next sequential id (t1, t2, …) — short and
|
// nextTodoID returns the next sequential id (t1, t2, …) — short and
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func TestTodoWriteAddReturnsItemAndPersists(t *testing.T) {
|
|||||||
assert.Contains(t, res.Output, "[ ] t1 — first task")
|
assert.Contains(t, res.Output, "[ ] t1 — first task")
|
||||||
|
|
||||||
// Persisted to disk so a fresh tool instance picks it up.
|
// Persisted to disk so a fresh tool instance picks it up.
|
||||||
path := filepath.Join(dir, ".felix", "todos.json")
|
path := filepath.Join(dir, ".harness", "todos.json")
|
||||||
data, err := os.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Contains(t, string(data), "first task")
|
assert.Contains(t, string(data), "first task")
|
||||||
@@ -145,8 +145,8 @@ func TestFormatTodosSortsByStatusThenID(t *testing.T) {
|
|||||||
|
|
||||||
func TestTodoWriteCorruptStoreSurfacesError(t *testing.T) {
|
func TestTodoWriteCorruptStoreSurfacesError(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
require.NoError(t, os.MkdirAll(filepath.Join(dir, ".felix"), 0o755))
|
require.NoError(t, os.MkdirAll(filepath.Join(dir, ".harness"), 0o755))
|
||||||
require.NoError(t, os.WriteFile(filepath.Join(dir, ".felix", "todos.json"), []byte("{not valid json"), 0o644))
|
require.NoError(t, os.WriteFile(filepath.Join(dir, ".harness", "todos.json"), []byte("{not valid json"), 0o644))
|
||||||
|
|
||||||
tool := &TodoWriteTool{WorkDir: dir}
|
tool := &TodoWriteTool{WorkDir: dir}
|
||||||
res, _ := tool.Execute(context.Background(), json.RawMessage(`{"op":"list"}`))
|
res, _ := tool.Execute(context.Background(), json.RawMessage(`{"op":"list"}`))
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ func (t *WebFetchTool) Execute(ctx context.Context, input json.RawMessage) (tool
|
|||||||
return tool.ToolResult{Error: fmt.Sprintf("invalid URL: %v", err)}, nil
|
return tool.ToolResult{Error: fmt.Sprintf("invalid URL: %v", err)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("User-Agent", "Felix/1.0 (AI Agent Gateway)")
|
req.Header.Set("User-Agent", "harness/1.0 (Go agent framework)")
|
||||||
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,text/plain;q=0.8,application/json;q=0.7,*/*;q=0.5")
|
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,text/plain;q=0.8,application/json;q=0.7,*/*;q=0.5")
|
||||||
for k, v := range in.Headers {
|
for k, v := range in.Headers {
|
||||||
req.Header.Set(k, v)
|
req.Header.Set(k, v)
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ func duckDuckGoSearch(ctx context.Context, query string, maxResults int) ([]sear
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req.Header.Set("User-Agent", "Felix/1.0 (AI Agent Gateway)")
|
req.Header.Set("User-Agent", "harness/1.0 (Go agent framework)")
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user