feat(harness-sdk): the kilo harness SDK - #5878
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summaries (9 snapshots, latest commit 1b6d23f)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 1b6d23f)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (14 files)
Fix these issues in Kilo Cloud Previous review (commit b1600c9)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous review (commit c5808bf)Status: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Previous review (commit 7556919)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Previous review (commit 7dc528e)Status: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous review (commit 7fe69c0)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Fix these issues in Kilo Cloud Previous review (commit 4766987)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (5 files)
Fix these issues in Kilo Cloud Previous review (commit dfc1b09)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (9 files)
Fix these issues in Kilo Cloud Previous review (commit 1f53424)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (7 files)
Reviewed by grok-4.6 · Input: 142.3K · Output: 6.1K · Cached: 451.7K Review guidance: REVIEW.md from base branch |
2e6d972 to
1b6d23f
Compare
|
bot: Accepted. Pushed 4c7df0a (kwf What changed:
|
1b6d23f to
4c7df0a
Compare
A new package,
@kilocode/harness-sdk. It holds a conversation with a model,keeps the model cache warm, stores the conversation, and summarises it when the
conversation outgrows the window.
One source runs on Node and on React Native. Nothing in
src/core/names aplatform:
fetch, SQLite and the source of random bytes are all plugin points.Read
packages/harness-sdk/README.mdfirst. It is what a consumer sees, andit is the fastest way to judge whether the shape is right.
AGENTS.mdis thesecond read: it holds why each decision was made and the measurement behind it.
Nothing on this branch imports the package, so it cannot change any behaviour
that runs today. #5895 is stacked on it and is the first consumer: the mobile
chat tab.
What it does
openSessiongives a handle.askstreams the answerback as events: text, thinking, tool calls, tool results, and a
donethatcarries the token counts and why the model stopped.
messages,responsesandchat_completions,from one internal model. A model the catalog knows nothing about is assumed to
speak all three, and the best one it actually speaks is used.
breakpoints do not move, which is what makes the provider's cache hit.
told a call is still running, carries on with what does not depend on it, and
the answer drives a round of its own when it lands. Four parties decide how
long it waits, in a fixed order.
questionToolasks the person;subagentToolhands atask to a session of its own and returns one answer.
node:sqliteor
expo-sqlite. A session can be continued, or cloned onto another model —which is how a person switches model mid-conversation without losing it.
The store plugins name no runtime type, so the package depends on neither.
keeps what it was told to keep.
How it is built
src/core/holds the contracts and the pure domain.src/plugins/holds everyimplementation, including the package's own defaults. A CI check asserts the
direction:
core/never importsplugins/.Eight plugin points, each a
Context.Tagwith a default this package owns:ModelClient,ToolRegistry,PromptAssembler,ModelCatalog,SessionStore,TokenSource,RetryPolicy,EntropySource.layerKilois the wiring almostevery caller writes; each part underneath is still swappable.
Nine entry points, so a consumer bundles only what they run. The conformance
checks and the shipped
fetchadapter each sit behind one of their own.Libraries do the work:
effectfor control flow, streams and resources,eventsource-parserfor SSE,typiafor validation, and the Anthropic andOpenAI SDKs as types only, so a wrong field name in a request body does not
compile. One exception is written down with its reason:
core/id.tsencodes aULID itself, because every
ulidbuild either dragsnode:cryptointo the coreor throws at import on a runtime with no global
crypto.typiaruns at compile time throughttsc, so no schema object exists at runtime and validation costs 0.005 us per event.
What proves it
pnpm test:e2e:allpnpm test:perfcheckStore,checkAssembler, shipped for plugin authorscheck:packageimports the built bundle from all 9 entry pointscheck:platformfails the build if it names a runtimecheck:migrationscatches the inlined SQL drifting from the schemaThe live runs are not in CI and must not be: they cost money and need a token.
They exist because a change to the wire or to the session has to be answered by
the provider, not by a fake.
Two matrices are recorded in
AGENTS.mdrather than described:history. A model whose provider caches at all reads above 0.99 of its input
from the cache.
payload the schema accepted. The subagent description was tuned against this
table until it did — two models had read the old text as naming the only two
uses, and answered that no tool of theirs could look a thing up.
Timing, measured rather than assumed: a 200 turn prompt assembles in under 20 us,
a whole request costs 48 us before the socket, and a streamed token costs 7 us
end to end against seconds of provider latency.
AGENTS.mdalso records oneoptimisation that was expected to be ten-fold and measured eleven percent, and
one memory measurement that was thrown away because it moved more than the thing
it was measuring.
Outside the package
.github/workflows/ci.yml— aharness-sdkjob, path-filtered, runningcheck:ci. The migration check is why it exists: nothing at run time noticeswhen the inlined SQL stops matching the schema.
.gitignore— the package'sdist/.pnpm-lock.yaml— the new dependencies.apps/web/AGENTS.md— ten linesnext devwrites into the file itself andre-adds when removed. Unrelated to this package; committed because that is
what the block asks for.
Not here