agents_core 0.2.0
agents_core: ^0.2.0 copied to clipboard
A Dart library for orchestrating multi-agent AI workflows with LM Studio integration. Create agents, manage conversations, execute Python in Docker, and coordinate multi-step pipelines.
Changelog #
0.2.0 — 2026-03-26 #
Features #
Agent Loop
AgentLoop— producer/reviewer orchestration loop that iterates a producer agent and a reviewer agent until an approval pattern is matched ormaxIterationsis reached.AgentLoopIteration— immutable record of a single loop iteration capturingindex,producerResult, andreviewerResult.AgentLoopResult— aggregated result withiterations,approvedflag, totalduration, and combinederrors.- New
example/agent_loop.dartdemonstrating a developer + QA review loop.
Bug Fixes #
File Context
- Fixed
FileContext._resolveto useUri.fileinstead ofUri.parseso that workspace paths containing spaces are handled correctly without percent-encoding artifacts.
0.1.2 — 2026-03-25 #
Improvements #
LM Studio Client
LmStudioHttpClientnow correctly throwsLmStudioHttpExceptionfor 4xx client errors instead of misclassifying them — improves error handling for authentication failures, not-found, and rate-limit responses.- Retry logic refined to only retry on transient (5xx/network) errors, not client errors.
Bug Fixes
- Fixed flaky retry-related test expectations caused by timing sensitivity in exponential backoff verification.
0.1.1 — 2026-03-25 #
Add API_KEY to AgentsCoreConfig
Configuration
- Optional
apiKeyparameter onAgentsCoreConfig— sent as aBearertoken in theAuthorizationheader when the LM Studio server requires authentication. Readable fromAGENTS_API_KEYviafromEnvironment(). Masked intoString()output to prevent accidental credential leakage. AgentsCoreConfig.copyWith()supportsclearApiKeyto explicitly remove an API key.
0.1.0 — 2026-03-25 #
First feature-complete release of agents_core.
Features #
Agent Framework
Agentabstract base class withrun(String task, {FileContext? context})method.SimpleAgent— single-round chat completion agent.ReActAgent— multi-turn Reason + Act loop with tool calling, configurablemaxIterationsandmaxTotalTokensbudget.AgentResult— structured output withoutput,tokensUsed,toolCallsMade,filesModified, andstoppedReason.
LM Studio Client
LmStudioClient— high-level typed API for LM Studio's OpenAI-compatible endpoints (chatCompletion,chatCompletionStream,chatCompletionStreamText,completion,completionStream,listModels).LmStudioHttpClient— HTTP transport with automatic retry and exponential backoff (maxRetries, configurabledelay).SseParser— Server-Sent Events stream transformer that handles multi-line data and[DONE]sentinels.
Data Models (OpenAI-compatible)
ChatMessageandChatMessageRoleenum (system,user,assistant,tool).ChatCompletionRequest/ChatCompletionResponse/ChatCompletionChoice.ChatCompletionChunk/ChatCompletionChunkChoice/ChatCompletionDeltafor streaming responses.CompletionRequest/CompletionResponse/CompletionChoice.CompletionUsage— token usage tracking.ToolDefinitionandToolCall/ToolCallFunctionfor function calling.LmModel— model listing response.
Configuration
AgentsCoreConfig— central configuration withlmStudioBaseUrl,defaultModel,requestTimeout,dockerImage,workspacePath, andlogger.AgentsCoreConfig.fromEnvironment()factory — readsLM_STUDIO_BASE_URL,AGENTS_DEFAULT_MODEL,AGENTS_DOCKER_IMAGE,AGENTS_WORKSPACE_PATH, andAGENTS_REQUEST_TIMEOUT_SECONDSfrom environment variables.AgentsCoreConfig.copyWith()for immutable modifications.Loggerabstraction withStderrLoggerandSilentLoggerimplementations.
File Context
FileContext— sandboxed file-system abstraction withread,write,append,delete,exists, andlistFiles(with glob filtering).- Path traversal protection on all file operations.
- Pre-built tool definitions:
readFileTool,writeFileTool,listFilesTool,appendFileTool, andcreateHandlers()factory.
Orchestrator
Orchestrator— sequential agent pipeline with sharedFileContext.AgentStep— static or dynamic (AgentStep.dynamic) task prompts with optionalconditionguards.OrchestratorResult— collectsstepResults,duration, anderrors.OrchestratorErrorPolicy—stop(default) orcontinueOnError.
Docker Integration
DockerClient— run containers, check availability, pull images.DockerRunResult— capturesstdout,stderr, andexitCode.
Python Execution
PythonToolAgent— pre-configuredReActAgentwith Docker-based Python execution and optional file tools.PythonExecutionTool— tool definition and handler factory for running Python code in sandboxed Docker containers.
Quick Functions
ask()— one-shot chat completion that manages client lifecycle.askStream()— streaming one-shot chat completion.Conversation— stateful multi-turn wrapper withsend(),sendStream(),setSystemPrompt(), andclearHistory().
Exception Hierarchy
AgentsCoreException— library base exception.LmStudioHttpException— non-2xx HTTP responses.LmStudioApiException— structured API errors withisModelNotFound,isContextLengthExceeded, andisRateLimitedhelpers.LmStudioConnectionException— transport failures withsocketError,httpError,timeout, andfromExceptionfactories.DockerNotAvailableException/DockerExecutionException.FileNotFoundException/PathTraversalException.SseParseException— malformed SSE data.
0.0.1 #
- Initial project scaffold.