Commit Graph
128 Commits
Author SHA1 Message Date
sausheong d199a33b1a Upgrade modelcontextprotocol/go-sdk to v1.8.0 2026-10-03 19:30:43 +08:00
sausheong 5a1983af2f Upgrade google.golang.org/genai to v1.72.0 2026-10-03 19:29:45 +08:00
sausheong e7f2641af5 Upgrade anthropic-sdk-go to v1.78.0 2026-10-03 19:28:49 +08:00
sausheong e10c8d2119 Add a commit-msg hook that rejects AI attribution trailers
Enable per clone with: git config core.hooksPath scripts/hooks
2026-10-03 19:28:07 +08:00
sausheong 40fb986b3f feat: MCP adapter falls back to structured content when a tool returns no text
Servers that return their result only as structuredContent (no TextContent
block) reached the agent as an empty result. Serialize StructuredContent to
JSON in that case; when text is present it still wins, since the MCP spec
has tools send the same data as text.
v0.6.1
2026-09-30 21:04:09 +08:00
sausheong 611198dc64 Document Harness v0.6.0 in README 2026-09-28 22:15:58 +08:00
sausheong 26f81ac21f feat: exa_search tool backed by the Exa Search API
ExaSearchTool (tools/web) calls POST https://api.exa.ai/search with
query-relevant highlights, optional category, domain and published-date
filters, and the shared SSRF-safe search client.
v0.6.0
2026-09-28 15:13:10 +08:00
sausheong d47a71f779 feat: Stagehand natural-language browser tool
Add tools/stagehand, a browser tool built on the Stagehand Go SDK
(act/observe/extract/navigate/get_text/screenshot) with persistent named
sessions. Runs on local Chrome by default or Browserbase when an API key
is configured. Stagehand's internal inference is routed through the
harness LLMProvider via NewGenerateFunc, so it shares the agent's
provider, usage observers and admission guards.

The Stagehand SDK requires Go 1.26, so the module now declares go 1.26.0.
v0.5.0
2026-09-28 01:25:08 +08:00
sausheong 62f3424f30 feat: PDF attachments as Anthropic document blocks
Reuses llm.ImageContent/session.ImageData with MimeType
"application/pdf" rather than adding a new field: images already flow
tool result -> session entry -> reload -> provider end to end, so a
MIME check at the provider edge is the smallest change.

- Anthropic provider emits a document block (source.type=base64,
  media_type=application/pdf) for a PDF attachment in a tool result or
  a user message; images are unaffected. Cache control now also
  applies to document blocks.
- OpenAI provider replaces a PDF attachment with a text placeholder
  instead of an invalid image_url data URI; images still emitted.
  Gemini already accepts application/pdf inline and needs no change.
2026-09-26 00:41:54 +08:00
sausheong a1f34cce4c Send adaptive low-effort thinking for Opus 5.5 when reasoning is off
Opus 5.5 returns 400 on thinking {type:"disabled"}, and its ID matched the
"claude-opus-5" marker, so it inherited Opus 5's explicit disabled config.
2026-09-23 19:18:37 +08:00
sausheong 9a013f6f4b Raise WebFetchTool's output cap to ~1M tokens
MaxOutputLength was 50,000 chars, truncating fetched pages to a few
paragraphs well before hitting any model's context window. Match Sonnet
5's 1M-token context using this codebase's 4-chars/token estimate
(session.Session.EstimateTokens), and raise the raw HTTP read cap
(maxFetchSize) to 8MB so plain-text/JSON responses that don't shrink
during HTML->markdown conversion aren't cut short before the output cap
even applies.
2026-09-22 17:45:40 +08:00
sausheong 1e5b6599bb Document Harness v0.4.2 response handling and tool events 2026-09-13 21:19:39 +08:00
sausheong 3ca0994437 Reject empty and truncated answers and expose complete tool calls v0.4.2 2026-09-11 23:48:25 +08:00
sausheong 019a38f111 Fix repeated stream finishes and preserve cancellation causes v0.4.1 2026-09-10 16:34:12 +08:00
Chang Sau Sheong 3170b28251 Merge pull request #5 from sausheong/codex/update-readme-v0.4.0
Document Harness v0.4.0 capabilities
2026-09-10 07:57:45 +08:00
sausheong 036fe1e547 Document Harness v0.4.0 capabilities 2026-09-10 07:45:54 +08:00
Chang Sau Sheong 4cec5b57f8 Merge pull request #4 from sausheong/codex/hand-release-v0.4.0
Prepare Harness v0.4.0: execution isolation and durable runtime
2026-09-10 01:15:20 +08:00
sausheong 5d4632ffe3 Place macOS qualification workspaces in Colima shared home v0.4.0 2026-09-10 00:52:13 +08:00
sausheong a1c4d5d78c Provision hosted macOS Docker and avoid fixture build engine dependency 2026-09-10 00:37:33 +08:00
sausheong cc756425e8 Prepare and record Docker qualification fixtures 2026-09-10 00:23:04 +08:00
sausheong 0972eed3ea Harden Harness runtime, persistence and execution for Hand 2026-09-09 22:55:55 +08:00
sausheong 09c30fe2d5 Update README: bump stale version references to v0.3.9
Both "Status" mentions were still pinned at v0.3.6 (three releases
behind). Also documents Runtime.DynamicIdentityHint in the components
table — added this session, previously undocumented outside code
comments.
2026-09-07 21:06:05 +08:00
sausheong 50b791d3b6 Rename providers/ollama to providers/local
Ollama is one local-model server among several (LM Studio, llama.cpp's
server, vLLM, ...) that all speak the same OpenAI-compatible shape —
naming the package (and provider name downstream) after one of them
was misleading. Same constructor, same default endpoint (Ollama's,
being the most common), just generically named: NewLocalProvider.

This renames a package published minutes ago in v0.3.8 with no other
known consumers yet, so no compatibility shim is kept.
v0.3.9
2026-09-07 13:27:58 +08:00
sausheong 3b5aadb31f Add an ollama provider for local models
Thin constructor over the existing OpenAI-compatible path, same shape
as litellm/openrouter: NewOllamaProvider(baseURL) defaults to Ollama's
local endpoint (http://localhost:11434/v1) and needs no API key, since
Ollama doesn't authenticate requests. Also covers other local servers
that share Ollama's OpenAI-compatible endpoint shape (LM Studio,
llama.cpp's server, vLLM).
v0.3.8
2026-09-07 11:57:56 +08:00
sausheong 897643db18 Add a regression test proving a mid-session model switch is real
Verifies, at the Runtime.Run level, that mutating Model and
DynamicIdentityHint between two Run calls in the same session (exactly
what hand's tui.Controller.SwitchModel does) actually changes the
ChatRequest.Model sent on the next call, not just the system prompt
text. If this ever regressed, a caller-side "/model" fix would look
correct in its own unit tests while the model actually being queried
silently stayed the old one.
v0.3.7
2026-09-07 00:22:07 +08:00
sausheong 0ccfdb2a24 Add Runtime.DynamicIdentityHint, a live, per-turn identity fact
Runtime.StaticSystemPrompt is cached and reused verbatim every turn —
right for anything that doesn't change mid-conversation, wrong for a
fact a caller needs to update live (e.g. after a runtime model switch)
and have the model actually notice. A model tends to just repeat what
it already told the user earlier in the same conversation over a
background instruction it read once near the top of a large cached
block, so updating only the static prompt after a switch left the
model insisting it was still whatever it started as.

DynamicIdentityHint rides the same per-turn (uncached) system prompt
slot Run/RunTurn already use for the date line and KG hint, so setting
it takes effect on the very next turn with the same recency the model
grants its own last statement.
2026-09-07 00:15:23 +08:00
sausheong f624e4c7bd Replace Qwen provider with LiteLLM and OpenRouter aggregators
Adding one bespoke provider package per vendor doesn't scale. LiteLLM
proxy and OpenRouter both speak the OpenAI chat-completions wire
format and each front dozens-to-hundreds of underlying models, so
supporting them once gets that whole catalog instead of one more
one-off integration — providers/qwen turns out to have been exactly
that pattern hand-rolled a second time (its own copy of the
OpenAI-compatible translation, just pointed at DashScope's base URL).

providers/litellm and providers/openrouter are both thin constructors
over the OpenAI provider's existing NewOpenAIProviderWithKind(apiKey,
baseURL, "openai-compatible") — no new request/stream-translation code.
OpenRouter defaults to its public endpoint when baseURL is empty;
LiteLLM has none (self-hosted), so callers must supply one.

Context-window detection (tokens.ContextWindow) already keys off the
model ID's family rather than the provider prefix, specifically so a
model exposed under a custom/proxy provider name still gets the right
window — so litellm/openrouter models need zero changes there.
2026-09-06 16:13:30 +08:00
sausheong 0ba1b4dbcc fix(tokens): generalize Gemini context-window detection by tier
windowByModelFamily matched Gemini models by exact version substring
("gemini-1.5-pro", "gemini-1.5-flash", "gemini-2"), so any newer
generation (3.x and beyond) fell through to defaultRemoteUnknownWindow
(128k) purely because this table hadn't been updated yet — observed
via hand's status line showing a >100% context gauge for a
"gemini-3.8-flash"-family model whose real window is far larger, and
which made harness's own preventive compaction unreachable (the
threshold check never fires against a window this far off).

Match on tier (Pro vs. everything else) instead of enumerating every
version: every Pro-tier Gemini release so far ships 2M, everything
else at least 1M, and both hold for a model this table has never seen
the exact version string of.
2026-09-05 22:06:59 +08:00
sausheong 986c233d39 fix: preserve native Anthropic inference controls v0.3.6 2026-08-17 03:43:30 +08:00
sausheong 8e92125fb6 docs: bump README to v0.3.5 v0.3.5 2026-08-02 10:18:14 +08:00
sausheong eb4fa67976 fix: harden runtime against panics/races, close path-traversal and fail-open gaps
- Runtime.Run rejects concurrent invocations instead of racing on shared state; panics in tools, hooks, and permission checkers are recovered and surfaced as errors/denials instead of crashing the loop
- AgentSpec.Loop now actually overrides RuntimeDeps.AgentLoop per-agent, as documented
- session.Store validates agent ID / session key as single path components, preventing traversal outside the session directory
- ValidatePathInWorkDir resolves symlinks on the target itself, not just its parent, closing a workspace-escape gap
- bash tool now fails closed on an unrecognized ExecPolicy.Level instead of allowing everything
- browser tool rejects unknown actions instead of silently no-op'ing

Bump README to v0.3.4 and document the AgentSpec.Loop override semantics.
2026-08-02 10:14:20 +08:00
sausheong 445614757b fix: support Claude Opus 5 / Sonnet 5 adaptive thinking; unique Gemini tool-call IDs
Anthropic: add claude-opus-5 and claude-sonnet-5 to the adaptive-thinking-only
model list. These models also think by default when the thinking param is
omitted (unlike Fable 5/Mythos/Opus 4.7/4.8), so ReasoningOff now sends an
explicit {type:"disabled"} on them instead of relying on omission.

Gemini: replace the empty-FunctionCall.ID fallback (function name) with a
synthetic toolu_-shaped random ID. The name-based fallback wasn't unique —
repeated calls to the same tool in one conversation collided on one ID,
which produced duplicate tool_use ids if that history was later replayed to
a different (Anthropic) model on a routing switch, rejected with a 400.
2026-07-28 13:40:22 +08:00
sausheong c7846eeab9 feat: preserve Anthropic prompt cache controls v0.3.4 2026-07-20 08:21:59 +08:00
sausheong 0300af6717 fix: capture thinking blocks in ChatNonStreaming fallback path v0.3.3 2026-07-12 21:01:02 +08:00
sausheong 152d8b972e feat: preserve and echo thinking blocks for extended-thinking models (DeepSeek, Claude thinking mode) 2026-07-12 20:30:48 +08:00
sausheong d3c74e5681 docs: drop Co-Authored-By trailer references from run-total-usage plan v0.3.2 2026-06-26 23:35:05 -07:00
sausheong d1c63cac56 Merge run-total-usage: emit run-total token usage on terminal EventDone
Runtime.Run now accumulates token usage across all turns (summing all four
llm.Usage fields via a pure addUsage helper) and emits the run total on the
terminal EventDone, instead of only the last turn. Fixes multi-turn undercount
for consumers metering AgentEvent.Usage. RunTurn unchanged (one turn per call).
2026-06-26 22:28:04 -07:00
sausheong ef3a1d4927 test(runtime): assert addUsage returns a distinct pointer (aliasing safety) 2026-06-26 21:41:23 -07:00
sausheong 2f97b1cf78 docs(runtime): clarify EventDone.Usage is the run total 2026-06-26 21:37:28 -07:00
sausheong 69f58903eb fix(runtime): emit run-total token usage on terminal EventDone
Run accumulated only the last turn's usage into the terminal EventDone, so
multi-turn runs under-reported tokens to consumers metering AgentEvent.Usage.
Sum all four usage fields across turns; RunTurn is unchanged (one turn/call).
2026-06-26 21:33:58 -07:00
sausheong 1ec0f9cac3 feat(runtime): add pure addUsage helper for field-wise usage summation 2026-06-26 21:29:27 -07:00
sausheong 2630d88245 docs: implementation plan for run-total token usage 2026-06-26 21:28:10 -07:00
sausheong a797d446f8 docs: design for run-total token usage on terminal EventDone 2026-06-26 21:07:11 -07:00
sausheong ac724d18e1 Merge branch 'security/s1-bash-bypass': close S1 bash allowlist bypass
Fix the CRITICAL allowlist-confinement escape: the metacharacter guard
checked the two-byte literal "\\n" instead of a real newline, so a
newline in the command ran subsequent lines unchecked via bash -c. Also
treat background & as a command separator and reject output redirection
(>) in allowlist mode.
2026-06-13 16:34:00 +08:00
sausheong 7f0c3fd23d fix(bash): reject real newline/CR and redirection in allowlist mode (S1) 2026-06-13 16:25:44 +08:00
sausheong a5f21d3a2c fix(bash): treat background & as a command separator in allowlist mode (S1) 2026-06-13 16:23:51 +08:00
sausheong 34435736c5 Merge branch 'cleanup/low-batch': low-priority sweep (L1/L3/L4/L5/L10)
tokens image accounting, Qwen usage stats, one-time degraded-persistence
warning (AppendEntry+Rewrite), RunSync abort surfacing, retry classifier
bounded 429/529 forms + typed Gemini APIError path.
2026-06-13 15:57:04 +08:00
sausheong 3da8fe8ed3 fix(llm): recognize Gemini 429/5xx as retryable via typed APIError path 2026-06-13 15:52:33 +08:00
sausheong 9292731d79 fix(llm): scope retry classifier to bounded 429/529 forms 2026-06-13 15:34:19 +08:00
sausheong 04f02c56d6 fix(runtime): RunSync returns context.Canceled on aborted run 2026-06-13 15:33:02 +08:00