LLM Integration

ASTRA agents can use large language models (LLMs) for work that is hard to program as rules: interpreting text, proposing plans, explaining decisions or answering open-ended questions. ASTRA keeps control of the agent. Its plans decide when a model is consulted, what context the model receives, and what is done with the reply. A model’s suggestion becomes an action only when a plan decides to act on it.

This section shows how to use that combination with ASTRA 2.8.4, using Java 17 or later.

Two libraries

The integration is delivered by two libraries, both released with ASTRA:

Library

Provides

astra-langchain4j

Model access through LangChain4j, templates, belief-based context, reusable reasoning agents, structured tools, reasoning memory, capability dispatch and shared A2A contracts

astra-langchain4j-tools

Standalone protocol adapters, including MCP and UTCP, HTTP capability bindings, JSON support and the A2A Inspector launcher

astra-langchain4j is all you need to call a model from an agent. Add astra-langchain4j-tools when an agent must communicate with agents or services outside its ASTRA program.

How the parts fit together

The section builds up in layers:

  • Model access. The LLMModel module sends a prompt to a provider such as OpenAI, Google Gemini or Anthropic and returns the reply. Templater builds prompts from templates and extracts values from replies. See Your first LLM agent and Prompts, responses and beliefs.

  • Reasoning architecture. The astra.langchain4j.reasoning package contains agent classes that implement established prompting strategies: direct prompting, zero-shot and few-shot chain of thought, multi-step pipelines, ReAct, Thread of Thoughts and Tree of Thoughts. An agent adopts a strategy by extending its class and adopting the !solve(...) goal. See The reasoning architecture.

  • Agent-to-Agent communication. A2A is an open protocol that lets agents built with different frameworks discover each other’s skills and exchange tasks over HTTP. An ASTRA agent can publish its skills as an A2A service, or call other A2A agents, using ordinary rules and events. See Agent-to-Agent communication.

The ReActMCP agent also combines remote MCP tools and general ASTRA callable goals; see MCP and Callable Goals.

The layers combine. A reasoning agent can be published as an A2A service, and a ReAct agent can use a remote A2A agent as one of its tools.

What ASTRA contributes

A model on its own answers one prompt at a time. Placing it inside an agent adds the structure of a BDI program around those calls:

  • Goals and plans decide when the model is needed and what happens next. The reasoning agents are themselves ASTRA plans, so their control flow can be read, traced and changed.

  • Beliefs retain what the agent knows across calls. They configure the reasoning agents (worked examples, pipeline steps, tools) and supply context for prompts.

  • Rules and context conditions check a model’s proposal against the agent’s knowledge before it is acted on.

  • Failure handling (try/recover and ^! plans) recovers from provider errors, malformed replies and failed tools.

  • Communication lets specialist agents cooperate, whether through ASTRA messages or A2A.

Because the model is outside the agent’s control, its replies vary between runs and can be wrong. Validate a value before using it to act, bound the number of calls a strategy can make, and keep API keys out of version control.

Where to start

Follow the pages in order for a complete introduction:

  1. Your first LLM agent sets up a project and makes a model call.

  2. Prompts, responses and beliefs builds prompts from templates and beliefs, and extracts values from replies.

  3. The reasoning architecture introduces the reasoning agents. The pages that follow give an example of each strategy.

  4. Agent-to-Agent communication introduces A2A. Its pages publish an ASTRA agent as a service and call it from another agent.

The sample projects show larger applications, and the API reference summarises the modules, goals, beliefs and events used throughout.

Current agentic application APIs

Continue with unified capabilities, run management, memory and belief context, and standalone or MAMS integrations. These pages describe the ASTRA 2.8.4 APIs; older downloadable examples retain their stated versions.

Background

The integration and its motivation are described in astra-langchain4j: Experiences Combining LLMs and Agent Programming. The paper describes an earlier API. Some walkthroughs and sample projects retain older verified dependency versions; follow their version notes rather than assuming that every example has been migrated to the latest release. The source code is in the astra-core repository, in the astra-langchain4j and astra-langchain4j-tools modules. Their release history is in the release notes.