(WIP) Redesign agentic-kit core around structured streams and add minimal agent runtime#4
Open
(WIP) Redesign agentic-kit core around structured streams and add minimal agent runtime#4
agentic-kit core around structured streams and add minimal agent runtime#4Conversation
Author
|
added live ollama tests |
agentic-kit core around structured streams and add minimal agent runtimagentic-kit core around structured streams and add minimal agent runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR rewrites
agentic-kitfrom a thin text-generation adapter layer into a structured provider portability layer, and introduces a separate@agentic-kit/agentruntime package forsequential tool execution.
The new architecture is based on the redesign decisions captured in
REDESIGN_DECISIONS.md. It preserves a compatibility path for the existingAgentKit.generate()flow while establishing thenew long-term API around:
Why
The repo was previously too thin to serve as a serious provider-agnostic foundation in Constructive.
Before this PR, the library mostly offered:
It did not have:
This PR addresses those gaps systematically.
What Changed
Core
agentic-kitredesignAdded new core modules in
packages/agentic-kit/src/:types.tsevent-stream.tsmessages.tsmodel-registry.tsprovider-registry.tstransform-messages.tsThese introduce:
ModelDescriptorContextMessage/AssistantMessage/ToolResultMessagetext,image,thinking, andtoolCallUsageandStopReasonAssistantMessageEventstreamingNew top-level core API
packages/agentic-kit/src/index.tsnow exposes structured primitives:stream(model, context, options)complete(model, context, options)completeText(model, context, options)The old
AgentKitclass remains as a transition-layer compatibility wrapper.Compatibility wrapper retained
The legacy prompt-oriented API still works for one transition release through:
AgentKitcreateOpenAIKitcreateAnthropicKitcreateOllamaKitcreateMultiProviderKitThat wrapper now delegates into the structured event-stream architecture instead of being the primary abstraction.
OpenAI-compatible adapter rewrite
packages/openai/src/index.tswas rewritten around the new contract.It now supports:
Anthropic adapter rewrite
packages/anthropic/src/index.tswas rewritten to the same structured protocol.It now supports:
Ollama adapter rewrite
packages/ollama/src/index.tsnow includes:OllamaClientfunctionality for model listing, pull/delete, and embeddingsOllamaAdapterNew
@agentic-kit/agentpackageAdded a new package at
packages/agent/.This package provides a minimal v1 runtime:
This intentionally does not yet include richer steering/follow-up orchestration. The goal is to keep the first runtime layer minimal and validate the architecture first.
Docs and design record
Added:
REDESIGN_DECISIONS.mdUpdated:
README.mdpackages/agentic-kit/README.mdpackages/ollama/README.mdThis also removes stale Ollama documentation that referenced methods no longer present in code.
Test coverage refresh
Replaced old tests that assumed string-only adapter behavior with new tests covering:
Migration Notes
This PR changes the architectural center of gravity, but keeps a compatibility path.
The intended migration path is:
kit.generate({ model, prompt }, { onChunk })stream(model, context, options)orcomplete(model, context, options)Legacy usage still works, but the structured API is now the primary contract.
Verification
Executed successfully:
pnpm installpnpm -r buildpnpm -r testAdditional smoke checks performed:
packages/agentic-kit/dist/index.jspackages/agentic-kit/dist/esm/index.jspackages/agent/dist/esm/index.jsInfra / Packaging Notes
I found and fixed one real infra issue during this work:
dist/esm.Fix applied:
.jsspecifiers.jsrelative imports back to TS sources during testsCurrent remaining caveat:
dist/esm/*.jsby file path triggers Node’sMODULE_TYPELESS_PACKAGE_JSONwarning because the generateddist/package.jsonis not marked"type": "module"Follow-ups
Recommended next follow-ups after this PR:
@agentic-kit/agentorchestration only after the lower-level protocol proves stableFiles of Interest
Core:
packages/agentic-kit/src/index.tspackages/agentic-kit/src/types.tspackages/agentic-kit/src/event-stream.tspackages/agentic-kit/src/messages.tspackages/agentic-kit/src/model-registry.tspackages/agentic-kit/src/provider-registry.tspackages/agentic-kit/src/transform-messages.tsAdapters:
packages/openai/src/index.tspackages/anthropic/src/index.tspackages/ollama/src/index.tsAgent runtime:
packages/agent/src/agent.tspackages/agent/src/types.tspackages/agent/src/validation.tsDesign record:
REDESIGN_DECISIONS.md