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:
sausheong committed 2026-05-08 00:24:06 +08:00
1 parent 8ed38d7b66
commit 123a233cb7
22 files changed
+107 -85

No files matched your search

+22 -10
View File
@@ -1,9 +1,9 @@
# harness
A reusable Go agentic harness extracted from [Felix](https://github.com/sausheong/felix).
Implements the streaming agent loop, tool registry, session storage, compaction, and
token budgeting that drive a multi-provider LLM agent. BYO concrete tools, BYO
provider clients, BYO memory/knowledge-graph plugins.
A reusable Go agentic platform for building LLM agents. Implements the
streaming agent loop, tool registry, session storage, compaction, and
token budgeting needed to run a multi-provider agent in production. BYO
concrete tools, BYO provider clients, BYO memory/knowledge-graph plugins.
## 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}`.
Behavior is preserved verbatim — same partition algorithm, same compaction triggers,
same prompt cache stability rules, same token calibrator. Felix-specific pieces
(HTTP gateway, JSON5 config, MCP client, bundled Ollama, knowledge-graph adapter,
markdown skill loader, Telegram outbound, file-backed memory) stay in Felix.
The harness is intentionally minimal. Every agent gets:
- A streaming think-act loop with parallel tool dispatch
- A pluggable LLM provider interface (Anthropic, OpenAI, Gemini, Qwen
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
+3 -3
View File
@@ -48,9 +48,9 @@ func transcriptDelimiterSuffix() string {
// - Section 6 ("All user messages") is the load-bearing anti-drift
// mechanism. Without it, summarizers collapse multiple distinct user
// asks into a single sentence keyed off whichever topic came first,
// which causes the next turn to misframe the conversation (Felix bug
// post-mortem: model said "previous conversation covered Colima" when
// the most recent topic was Wasm/Extism).
// which causes the next turn to misframe the conversation — the
// resumed model says "previous conversation covered X" when the
// most recent topic was actually Y.
// - Section 9 ("Optional Next Step") demands verbatim quotes from the
// most recent messages so the resumed turn doesn't drift on task
// interpretation.
+4 -3
View File
@@ -13,9 +13,10 @@ import "github.com/sausheong/harness/session"
// that preserves K turns. Caller should refuse to compact rather than over-
// compacting.
//
// A user message is always a clean boundary by construction in Felix's
// runtime (user msg → assistant text → tool_call → tool_result → next user
// msg). Splitting before a user message therefore never orphans a tool pair.
// A user message is always a clean boundary by construction in the
// harness runtime (user msg → assistant text → tool_call → tool_result
// → 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) {
if K <= 0 || len(history) == 0 {
return nil, nil, false
+3 -3
View File
@@ -1,6 +1,6 @@
// data.gov.sg agent — a second non-Felix consumer of the harness framework
// that talks to Singapore's open-data APIs (real-time environment + CKAN
// dataset catalog).
// data.gov.sg agent — example agent built on harness that talks to
// Singapore's open-data APIs (real-time environment + CKAN dataset
// catalog).
//
// Composition surface used (identical to lta-agent):
// - tool.Registry (BYO concrete tools — none from harness/tools/*)
+3 -4
View File
@@ -1,5 +1,5 @@
// LTA Datamall agent — a non-Felix consumer of the harness framework
// that proves the API isn't accidentally Felix-shaped.
// LTA Datamall agent — example of building a domain-specific agent on
// the harness framework with custom tools (no harness/tools/* deps).
//
// Composition surface used:
// - tool.Registry (BYO concrete tools — none from harness/tools/*)
@@ -9,9 +9,8 @@
// - runtime.Run streaming loop
//
// Deliberately NOT used:
// - Skills, Memory, KnowledgeGraph (consumer doesn't need them)
// - Skills, Memory, KnowledgeGraph (this agent doesn't need them)
// - Subagents, compaction, calibrator persistence
// - Any Felix-specific config or path conventions
//
// Run:
//
+1 -1
View File
@@ -382,7 +382,7 @@ func TestBuildMessageParamsIsPure(t *testing.T) {
MaxTokens: 4096,
Temperature: 0.7,
SystemPromptParts: []llm.SystemPromptPart{
{Text: "you are felix", Cache: true},
{Text: "you are an assistant", Cache: true},
{Text: "today is 2026-05-01"},
},
Messages: []llm.Message{
+5 -4
View File
@@ -44,9 +44,10 @@ func TestBuildStaticSystemPromptIdentity(t *testing.T) {
require.NoError(t, err)
// Consumers wanting "configuration file is at ..." in the static prompt
// pass it through deps.ConfigSummary; the harness no longer hard-codes
// Felix's config path. Verify the agent identity + IDENTITY.md content
// land verbatim, plus that a caller-supplied config summary is honoured.
// pass it through deps.ConfigSummary; the harness does not hard-code
// any config path of its own. Verify the agent identity + IDENTITY.md
// content land verbatim, plus that a caller-supplied config summary
// is honoured.
result := BuildStaticSystemPrompt(dir, "", "test", "Test Agent",
[]string{"read_file", "bash"}, "configuration file is at /tmp/x.json", "", "", "")
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
// full original content, and the path embedded in the message is
// 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.True(t, filepath.IsAbs(wantPath))
data, err := os.ReadFile(wantPath)
+6 -4
View File
@@ -25,8 +25,9 @@ type RuntimeDeps struct {
// KGFn returns the per-agent KnowledgeGraph for the given model
// 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 chatting agent's own model to the KG's underlying LLM (Felix
// uses this to mirror the chat model into Cortex's extractor).
// the chatting agent's own model to the KG's underlying LLM — useful
// when the KG runs an extractor on the same provider/model as the
// agent itself.
KGFn func(model string) KnowledgeGraph
// AgentLoop carries the loop tunables (concurrency cap, depth cap,
// streaming-tools toggle). Copied verbatim into every Runtime built
@@ -42,8 +43,9 @@ type RuntimeDeps struct {
// changes only on hot-reload.
ConfigSummary string
// MemoryFiles, when non-empty, is appended to the static system
// prompt. Consumers compose this themselves (Felix walks
// FELIX.md / AGENTS.md from workspace + $HOME).
// prompt. Consumers compose this themselves — typical pattern is to
// concatenate AGENTS.md (and any project-specific identity files)
// from the workspace and the user's $HOME.
MemoryFiles string
}
+4 -4
View File
@@ -36,10 +36,10 @@ func TestBuildRuntimeMinimalSpecSafe(t *testing.T) {
}
func TestBuildRuntimeUsesCallerProvidedMemoryFiles(t *testing.T) {
// Caller composes memoryFiles however they want (Felix walks
// FELIX.md/AGENTS.md from workspace + $HOME; other consumers may
// build it from a wiki dump, a doc index, etc.). Harness only
// concatenates it into the static prompt.
// Caller composes memoryFiles however they want — typical patterns
// include walking AGENTS.md from workspace + $HOME, building from a
// wiki dump, or pulling from a doc index. Harness only concatenates
// it into the static prompt.
const sentinel = "MEMFILE_END_TO_END_SENTINEL"
deps := RuntimeDeps{
MemoryFiles: "\n\n## Project memory: AGENTS.md\n\n" + sentinel,
+9 -7
View File
@@ -86,12 +86,14 @@ func buildDefaultIdentity(toolNames []string) string {
// per-turn. Suitable to call once at Runtime construction.
//
// configSummary is the consumer's place to advertise things like the
// configured agents, channel bindings, configuration paths, or any other
// hot-reload-bound context. Felix uses it to inject a list of configured
// agents and the path to felix.json5; other consumers can leave it empty.
// configured agents, channel bindings, configuration paths, or any
// other hot-reload-bound context. Leave empty if you have nothing to
// surface.
//
// 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(
workspace, systemPrompt, agentID, agentName string,
toolNames []string,
@@ -404,7 +406,7 @@ const (
// without a workspace working unchanged.
//
// 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) +
// spillMarker pointing the model at the absolute path so it can recover
// 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 == "" {
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 {
return "", fmt.Errorf("spill mkdir: %w", err)
}
@@ -440,7 +442,7 @@ func spillToolResult(cfg spillConfig, toolCallID, content string) (string, error
//
// Two modes:
// - 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
// to <abs path>; use read_file to access the full output]". The
// model can recover the entire output via read_file, eliminating the
+4 -4
View File
@@ -14,12 +14,12 @@ import (
//
// Mirrors the path layout used by spillToolResult in context.go:
//
// <workspace>/.felix/spill/<sessionKey>/
// <workspace>/.harness/spill/<sessionKey>/
func SpillDirForSession(workspace, sessionKey string) string {
if workspace == "" || sessionKey == "" {
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.
@@ -42,7 +42,7 @@ func SpillRoot(workspace string) string {
if workspace == "" {
return ""
}
return filepath.Join(workspace, ".felix", "spill")
return filepath.Join(workspace, ".harness", "spill")
}
// LiveSessionKeysFn returns the set of currently-existing session keys for
@@ -51,7 +51,7 @@ func SpillRoot(workspace string) string {
// session JSONL on disk).
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.
// 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.
+2 -2
View File
@@ -36,8 +36,8 @@ type SubagentBuildFn func(spec AgentSpec) (RuntimeInputs, error)
type SubagentSpec struct {
Spec AgentSpec
// Registered reports whether the consumer considers this subagent ID
// valid for parent-driven invocation. Mirrors Felix's
// AgentConfig.Subagent flag.
// valid for parent-driven invocation. False prevents a parent agent
// from spawning this child via the task tool.
Registered bool
// InheritContext, when true, copies the parent session's view into
// the child session before BuildRuntime fires.
+3 -3
View File
@@ -229,9 +229,9 @@ loop:
}
// TestRun_SubagentDepthCapEnforced verifies the cap stops construction past
// the configured limit. With FELIX_MAX_AGENT_DEPTH=2, a parent at depth 0
// can call a subagent (depth 1), and that subagent can call another (depth 2),
// but a third-level attempt (depth 3) must fail with the cap error and the
// the configured limit. With MaxAgentDepth=2, a parent at depth 0 can call
// a subagent (depth 1), and that subagent can call another (depth 2), but
// a third-level attempt (depth 3) must fail with the cap error and the
// would-be subagent's RuntimeInputs builder must NOT be invoked.
//
// Note: this test reimplements the factory wiring rather than calling
+7 -6
View File
@@ -6,11 +6,11 @@ import (
"github.com/sausheong/harness/llm"
)
// testCfg is the harness test analogue of Felix's *config.Config — bundles
// a SubagentResolver with the small accessor helpers (EligibleSubagents,
// GetAgent) that subagent tests reach for. Lets the subagent_test.go and
// inheritance_test.go call sites keep their `cfg.X()` shape after the
// extraction without rewriting every test.
// testCfg is a tiny stand-in for whatever live-config object a real
// consumer would hold. It bundles a SubagentResolver with the small
// accessor helpers (EligibleSubagents, GetAgent) that subagent tests
// reach for, so subagent_test.go and inheritance_test.go can keep
// their `cfg.X()` call shape.
type testCfg struct {
specs map[string]AgentSpec
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
// 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 {
t.Helper()
parent := AgentSpec{
+3 -3
View File
@@ -96,7 +96,7 @@ func NewTrace(agentID, model string) *Trace {
if otelTracer != nil {
_, t.span = otelTracer.Start(context.Background(), "agent.run",
trace.WithAttributes(
attribute.String("felix.trace_id", id),
attribute.String("harness.trace_id", id),
attribute.String("agent.id", agentID),
attribute.String("llm.model", model),
),
@@ -219,8 +219,8 @@ func (t *Trace) Summary() {
if t.span != nil {
t.span.SetAttributes(
attribute.Int64("felix.total_ms", total),
attribute.Int("felix.phase_count", len(t.phases)),
attribute.Int64("harness.total_ms", total),
attribute.Int("harness.phase_count", len(t.phases)),
)
t.span.End()
}
+15 -12
View File
@@ -5,10 +5,11 @@ import "context"
// AgentSpec is the framework's view of an agent. Consumers convert their
// own agent-config types into this struct before invoking BuildRuntime.
//
// Mirrors the fields Runtime actually consumes; Felix-specific options
// (per-agent tool policies, MCP server bindings, channel routing,
// inheritContext flag, subagent registration, identity files) live in the
// consumer's config and are resolved before this struct is filled in.
// Holds only the fields Runtime actually consumes. Anything richer that
// a consumer's config carries (per-agent tool policies, MCP server
// bindings, channel routing, inheritContext flags, subagent
// registration, identity files) is resolved by the consumer before this
// struct is filled in.
type AgentSpec struct {
// ID identifies the agent for logging, session paths, and subagent
// resolution. Used as session.Session.AgentID.
@@ -43,11 +44,10 @@ type AgentSpec struct {
Loop LoopConfig
}
// LoopConfig tunes the agent runtime's tool-execution behavior. Mirrors
// Felix's AgentLoopConfig with framework-side env-var fallbacks
// (HARNESS_MAX_TOOL_CONCURRENCY, HARNESS_MAX_AGENT_DEPTH,
// HARNESS_STREAMING_TOOLS) — Felix consumers may set the FELIX_* env vars
// instead by setting these fields explicitly from their own config block.
// LoopConfig tunes the agent runtime's tool-execution behavior. Each
// field has a built-in env-var fallback (HARNESS_MAX_TOOL_CONCURRENCY,
// HARNESS_MAX_AGENT_DEPTH, HARNESS_STREAMING_TOOLS); set the field
// explicitly from your own config to bypass the env vars.
type LoopConfig struct {
// MaxToolConcurrency caps parallel tool dispatch within a safe batch.
// 0 ⇒ env fallback then default 10.
@@ -91,7 +91,9 @@ type Message struct {
}
// 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
// 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
// %q not found" error to the parent LLM.
//
// Implementations typically read from a live config so subagent
// definitions hot-reload (Felix reads through *config.Config).
// Implementations typically read from a live config object (often via
// an atomic.Value) so subagent definitions hot-reload without
// restarting the runtime.
type SubagentResolver func(agentID string) (spec AgentSpec, registered bool, ok bool)
+4 -3
View File
@@ -15,8 +15,9 @@ import (
)
// ExpandHome rewrites a leading "~" or "~/" in p to the user's home directory.
// Other tildes (mid-path, "~user/...") are left alone — Felix never escalates
// privileges, so cross-user tilde expansion would silently fail anyway.
// Other tildes (mid-path, "~user/...") are left alone — the harness never
// escalates privileges, so cross-user tilde expansion would silently fail
// anyway.
//
// 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
@@ -156,7 +157,7 @@ func SanitizeLLMText(s string) 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 {
Name() string
Description() string
+1 -1
View File
@@ -268,7 +268,7 @@ func pathSubsNotice(subs [][2]string) string {
return ""
}
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 {
fmt.Fprintf(&b, " %q -> %q\n", s[0], s[1])
}
+3 -3
View File
@@ -32,7 +32,7 @@ type TodoItem struct {
}
// 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
// the same workspace.
//
@@ -175,7 +175,7 @@ func (t *TodoWriteTool) Execute(_ context.Context, input json.RawMessage) (tool.
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
// the agent knows the file needs manual repair rather than silently
// dropping work.
@@ -217,7 +217,7 @@ func (t *TodoWriteTool) save(items []TodoItem) error {
}
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
+3 -3
View File
@@ -30,7 +30,7 @@ func TestTodoWriteAddReturnsItemAndPersists(t *testing.T) {
assert.Contains(t, res.Output, "[ ] t1 — first task")
// 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)
require.NoError(t, err)
assert.Contains(t, string(data), "first task")
@@ -145,8 +145,8 @@ func TestFormatTodosSortsByStatusThenID(t *testing.T) {
func TestTodoWriteCorruptStoreSurfacesError(t *testing.T) {
dir := t.TempDir()
require.NoError(t, os.MkdirAll(filepath.Join(dir, ".felix"), 0o755))
require.NoError(t, os.WriteFile(filepath.Join(dir, ".felix", "todos.json"), []byte("{not valid json"), 0o644))
require.NoError(t, os.MkdirAll(filepath.Join(dir, ".harness"), 0o755))
require.NoError(t, os.WriteFile(filepath.Join(dir, ".harness", "todos.json"), []byte("{not valid json"), 0o644))
tool := &TodoWriteTool{WorkDir: dir}
res, _ := tool.Execute(context.Background(), json.RawMessage(`{"op":"list"}`))
+1 -1
View File
@@ -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
}
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")
for k, v := range in.Headers {
req.Header.Set(k, v)
+1 -1
View File
@@ -129,7 +129,7 @@ func duckDuckGoSearch(ctx context.Context, query string, maxResults int) ([]sear
if err != nil {
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)
if err != nil {