Skip to content

AgentCore is the reasoning engine at the heart of CLIver. It implements the Re-Act loop — send messages to an LLM, execute tools, feed results back, and continue until a final response is ready.

1. Receive user input
2. Build messages (system prompt + conversation history + user input)
3. Send to LLM
4. If the LLM returns a tool call → execute tools → go to step 3
5. If the LLM returns text → done, return the response

The loop runs up to 50 iterations by default, with a safety limit of 5 consecutive tool errors before stopping.

import asyncio
from cliver_core import AgentCore, ModelBindings, presets
from cliver_core.tools import discover_builtin_tools
async def main():
agent = AgentCore(
ModelBindings(llm=presets.deepseek(api_key="...")),
builtin_tools=discover_builtin_tools(),
)
response = await agent.chat("List the files in this directory.")
print(response.message.content)
await agent.aclose()
asyncio.run(main())
  • Embeddable. AgentCore has zero CLI dependencies — it takes Python objects and returns message objects.
  • Stateless instance, stateful calls. Conversation context is passed per call (conversation=), so one instance is safe for concurrent chats.
  • Bindings, not config files. Every model purpose — chat, image, video, TTS, ASR, embed, rerank — lives in ModelBindings.
  • Lazy call-time resolution. Extra tools, MCP servers, tool filters, and skill dispatch are resolved per chat()/stream() call.
  • Observable. Pass on_event= to receive inference and tool lifecycle events, including tool.start, tool.end, tool.error, and tool.permission_denied.

chat() returns the final CLIverResponse; stream() yields CLIverMessageChunk objects as content arrives. Both accept the same per-call options:

ParameterDescription
user_inputThe user’s message
system_promptAdditional system content for this call
conversationPrevious messages for multi-turn context
mediaImages/audio/video attached to the user message
extra_toolsAdditional tools for this call only
mcp_serversMCP server names to advertise for this call
tool_filterPredicate that narrows the advertised tool set
optionsWire request options; call site overrides binding defaults
max_iterationsMax Re-Act iterations (default 50)
execution_policyAmbient tool-execution policy for this call
skill_dispatchAdvertise the skill catalogue and dispatch tools (default on)

When finished, call await agent.aclose() to close providers the agent built.