Run an agent with a knowledge base and a tool
What you'll build: a trip planner for a small travel agency. It answers from the agency's three itinerary files and checks the live weather in a trip's base city.
An agent is three things you already have or can make in the dashboard: a prompt, the tools bound to that prompt, and the knowledge bases attached to the agent. AcruxCore runs the whole loop, not your app. It calls the model, runs each search and each tool call, and feeds the results back until the model has an answer. Your app sends one message and gets the answer back. Every step lands in one trace.
Each step below is done in the dashboard. Under each one, Do this in code shows the same step with the Python and Node SDKs.
Before you start
You need two models registered under Gateway → Models: a chat model that can call
tools, and an embedding model. Set each model's Kind to match, Chat or Embedding: the
agent's Model list shows only chat models, and the knowledge base's Embedding model list
shows only embedding models. This guide uses gpt-4o-mini and text-embedding-3-small
from OpenAI. Route calls through the gateway
shows how to add a provider key and a model.
Do this in code
Create an API key under Account & keys, then install the SDK and set two environment variables:
- Python (SDK)
- Node (SDK)
pip install acruxcore
export ACRUXCORE_API_KEY=acx_sk_...
export ACRUXCORE_BASE_URL=https://api.acruxcore.com/api/v1
npm install @acruxcoreai/sdk
export ACRUXCORE_API_KEY=acx_sk_...
export ACRUXCORE_BASE_URL=https://api.acruxcore.com/api/v1
The API takes a model's id, but the dashboard shows only the model's name. models.list()
returns both, so the snippets below look each id up by name:
- Python (SDK)
- Node (SDK)
from acruxcore import AcruxCore
async with AcruxCore() as hub:
model_ids = {m.public_name: m.id for m in await hub.models.list()}
import { acruxcore } from '@acruxcoreai/sdk';
const hub = new acruxcore();
const models = await hub.models.list();
const modelId = (name) => {
const model = models.find((m) => m.publicName === name);
if (!model) throw new Error(`No gateway model named ${name}`);
return model.id;
};
1. Create the knowledge base
Open Knowledge and click New knowledge base.
- Kind: keep Documents. A documents base is searched by meaning. A Tables base holds CSV and Excel files that the agent queries with SQL instead; see Let an agent count and filter a spreadsheet.
- Name:
Trip itineraries. The agent's search tool is named after it:search_trip_itineraries. - Description:
The agency's trip itineraries: destination, season, price and day-by-day plan.The model reads this text to decide when to search, so say what is inside. - Embedding model:
text-embedding-3-small. Before saving, AcruxCore embeds one test text with the model, so a model that cannot embed is rejected here. - Chunking method: keep Paragraphs and sentences, with Chunk size
500and Overlap50. Each document is split at paragraph and sentence breaks into chunks of about 500 tokens, and neighbouring chunks share 50 tokens.

Click Create. You can change the embedding model later only while the knowledge base has no documents, because every chunk is embedded with that model.
Do this in code
- Python (SDK)
- Node (SDK)
kb = await hub.knowledge_bases.create(
"Trip itineraries",
embedding_model_id=model_ids["text-embedding-3-small"],
description="The agency's trip itineraries: destination, season, price and day-by-day plan.",
)
const kb = await hub.knowledgeBases.create({
name: 'Trip itineraries',
embeddingModelId: modelId('text-embedding-3-small'),
description: "The agency's trip itineraries: destination, season, price and day-by-day plan.",
});
2. Add the itineraries and test a search
Download the three itinerary files from
data/itineraries.
Each is a short Markdown file with a trip's season, base city, price and daily plan.
On the knowledge base's page, click Choose files and pick all three. You can also drop
files on the page, or click Paste text to add text without a file. A knowledge base
takes .txt, .md, .pdf and .docx files of up to 10 MB each.
Each file is chunked and embedded in the background. Its status goes from Queued to Processing to Ready within a few seconds. A file whose processing fails shows Failed with the reason, and a Retry button.
Under Test a search, type a trip with snow and click Search. You get the chunks the
agent would get for that query, closest first:

The score is 1 − cosine distance between the query and the chunk, so higher means
closer. The Lapland trip comes first although its text never says "snow". It says
"winter", "husky safari" and "-20 C", and the embeddings of those words are close to the query's.
Do this in code
upload_files takes file paths. Processing runs in the background, so wait until every
document is ready before you search:
- Python (SDK)
- Node (SDK)
import asyncio
from pathlib import Path
await hub.knowledge_bases.upload_files(kb.id, sorted(Path("data/itineraries").glob("*.md")))
while not all(d.status == "ready" for d in await hub.knowledge_bases.list_documents(kb.id)):
await asyncio.sleep(1)
hits = await hub.knowledge_bases.search(kb.id, "a trip with snow", top_k=1)
print(hits[0].filename, round(hits[0].score, 2)) # lapland-northern-lights.md 0.42
import { readdirSync, readFileSync } from 'node:fs';
const dir = 'data/itineraries';
const files = readdirSync(dir).map((filename) => ({ filename, data: readFileSync(`${dir}/${filename}`) }));
await hub.knowledgeBases.uploadFiles(kb.id, files);
while (!(await hub.knowledgeBases.listDocuments(kb.id)).every((d) => d.status === 'ready')) {
await new Promise((resolve) => setTimeout(resolve, 1000));
}
const [hit] = await hub.knowledgeBases.search(kb.id, 'a trip with snow', { topK: 1 });
console.log(hit.filename, hit.score.toFixed(2)); // lapland-northern-lights.md 0.42
A document whose status is failed has its reason in error. The full setup script
stops on one.
3. Create the weather tool
The agent gets the weather from wttr.in, which needs no API key. You describe the HTTP request once, and AcruxCore makes it each time the model calls the tool.
Open Tools and click New tool:
- Name:
get_trip_weather. - Description:
Get the current weather and a three-day forecast for one city. - Parameters: one row,
city, typestring, marked req, described asCity name, e.g. 'Rovaniemi'.Tick Reject arguments not listed above. - Executor: HTTP — AcruxCore calls a URL for you, method
GET, URLhttps://wttr.in/{{arg.city}}. The{{arg.city}}placeholder is replaced with the city the model passes. - Query params: one row,
format=j1, which asks wttr.in for JSON.

wttr.in returns about 40 KB of JSON. Paste this Response transform so the model gets only the current conditions and the daily highs and lows:
function transform(input) {
const now = input.body.current_condition[0];
return {
temp_c: Number(now.temp_C),
feels_like_c: Number(now.FeelsLikeC),
conditions: now.weatherDesc[0].value,
forecast: input.body.weather.map((d) => ({ date: d.date, max_c: Number(d.maxtempC), min_c: Number(d.mintempC) })),
};
}
Click Create tool. Create a tool covers every field in this dialog.
An agent runs on AcruxCore, so it can only call tools that AcruxCore can run: HTTP tools and knowledge-base searches. A prompt with a Client tool bound to it cannot run as an agent, and the agent's page says so.
Do this in code
A tool is created in two calls: the tool itself, then its first version with the
parameters and the executor. The transform above is saved as
data/weather_transform.js.
- Python (SDK)
- Node (SDK)
from pathlib import Path
tool = await hub.tools.create("get_trip_weather")
await hub.tools.commit_version(
tool.id,
description="Get the current weather and a three-day forecast for one city.",
parameters_schema={
"type": "object",
"required": ["city"],
"properties": {"city": {"type": "string", "description": "City name, e.g. 'Rovaniemi'."}},
"additionalProperties": False,
},
executor={
"type": "http", "method": "GET", "url": "https://wttr.in/{{arg.city}}",
"query": [{"name": "format", "value": "j1"}],
"responseTransform": Path("data/weather_transform.js").read_text(),
},
)
import { readFileSync } from 'node:fs';
const tool = await hub.tools.create({ name: 'get_trip_weather' });
await hub.tools.commitVersion(tool.id, {
description: 'Get the current weather and a three-day forecast for one city.',
parametersSchema: {
type: 'object',
required: ['city'],
properties: { city: { type: 'string', description: "City name, e.g. 'Rovaniemi'." } },
additionalProperties: false,
},
executor: {
type: 'http', method: 'GET', url: 'https://wttr.in/{{arg.city}}', headers: [],
query: [{ name: 'format', value: 'j1' }],
responseTransform: readFileSync('data/weather_transform.js', 'utf8'),
},
});
4. Create the prompt and connect the tool
The prompt holds the agent's instructions. Open Prompts, click New prompt, name it
trip-planner and click Create prompt. In the System message, write:
You are a trip planner for a small travel agency.
Only recommend trips that exist in the agency's itineraries: search them before answering.
When the traveller asks about current conditions, check the weather for the trip's base city.
Quote the trip's name, season and price exactly as the itinerary states them.

Click Commit new version. The first version gets the production and staging
aliases, and the agent will run whichever version production points to. Leave
Default model empty, because the agent sets its own model in step 5.
Open the prompt's Tools tab, click + Connect a tool from the catalog and pick
get_trip_weather. It saves straight away and follows the tool's production alias:

The knowledge base is not connected here. You attach it to the agent in the next step, and the agent turns the knowledge base into a search tool.
Do this in code
- Python (SDK)
- Node (SDK)
SYSTEM_PROMPT = Path("data/system-prompt.txt").read_text()
prompt = await hub.prompts.create("trip-planner")
await hub.prompts.commit_version(prompt.id, [{"role": "system", "content": SYSTEM_PROMPT}])
await hub.prompts.set_tool_binding(prompt.id, tool.id, tool_alias="production")
const SYSTEM_PROMPT = readFileSync('data/system-prompt.txt', 'utf8');
const prompt = await hub.prompts.create({ name: 'trip-planner' });
await hub.prompts.commitVersion(prompt.id, { messages: [{ role: 'system', content: SYSTEM_PROMPT }] });
await hub.prompts.setToolBinding(prompt.id, tool.id, { toolAlias: 'production' });
data/system-prompt.txt
holds the system message above.
5. Create the agent
Open Agents and click New agent:
- Name:
Trip planner. Your code can run the agent by this name or by its id. - Prompt:
trip-planner, Alias:production (v1). - Model:
gpt-4o-mini. If you choose Prompt's default model instead, the agent uses the model bound to the prompt version. - Max steps: keep
8. That is the most model calls one message may take, so a model that keeps calling tools stops there. Each step runs at most 10 tool calls. - Knowledge: click Attach knowledge base and pick Trip itineraries. It appears
as a card that names the tool the model calls,
search_trip_itineraries. Set Results to return to3, the number of chunks one search returns. An agent can use up to five knowledge bases, and New knowledge base in the same dialog creates one without leaving the agent.

The card's Reranker and Decision model stay Off in this guide. Rerank and filter an agent's search results turns them on.
Click Create agent. The Tools panel lists every tool the model will see: the
weather tool from the prompt, and search_trip_itineraries from the knowledge base.

Do this in code
- Python (SDK)
- Node (SDK)
agent = await hub.agents.create(
"Trip planner",
prompt_id=prompt.id,
model_id=model_ids["gpt-4o-mini"],
knowledge_bases=[{"knowledge_base_id": kb.id, "top_k": 3}],
)
print([k.tool_name for k in agent.knowledge_bases] + [t["name"] for t in agent.tools])
# ['search_trip_itineraries', 'get_trip_weather']
const agent = await hub.agents.create({
name: 'Trip planner',
promptId: prompt.id,
modelId: modelId('gpt-4o-mini'),
knowledgeBases: [{ knowledgeBaseId: kb.id, topK: 3 }],
});
console.log([...agent.knowledgeBases.map((k) => k.toolName), ...agent.tools.map((t) => t.name)]);
// [ 'search_trip_itineraries', 'get_trip_weather' ]
6. Chat with the agent
On the agent's page, click Chat and ask:
I'd like a winter trip with snow. Which one do you have, what does it cost,
and what is the weather like there right now?
The agent answers in two tool calls. First the model searches the itineraries for
winter trip with snow and gets the Lapland trip. Then it calls get_trip_weather for
Rovaniemi, the trip's base city. Steps shows each call with its arguments and the
result the model received:

Below the steps comes the answer: the Lapland northern lights trip, winter, 1,450 EUR per person, and the current temperature in Rovaniemi. View trace opens the run's trace, with a span for each model call, search and tool call. The agent's Runs tab lists every run with its status.
Do this in code
agents.stream runs the agent and yields each step as it happens. agents.run waits and
returns the finished run instead.
- Python (SDK)
- Node (SDK)
QUESTION = "I'd like a winter trip with snow. Which one do you have, what does it cost, and what is the weather like there right now?"
async for event in hub.agents.stream("Trip planner", message=QUESTION):
if event.type == "step.llm":
for call in event.data.get("toolCalls") or []:
print(f" step {event.data['step']}: model calls {call['name']}({call.get('arguments')})")
elif event.type == "run.failed" and event.run is None:
# A run that fails before it is recorded carries only the error.
raise SystemExit(f"The run failed: {event.data['error']['message']}")
elif event.run is not None:
print(event.run.output)
const QUESTION = "I'd like a winter trip with snow. Which one do you have, what does it cost, and what is the weather like there right now?";
for await (const event of hub.agents.stream('Trip planner', { message: QUESTION })) {
if (event.type === 'step.llm') {
for (const call of event.toolCalls) console.log(` step ${event.step}: model calls ${call.name}(${call.arguments})`);
} else if (event.type === 'run.failed' && !event.run) {
// A run that fails before it is recorded carries only the error.
throw new Error(`The run failed: ${event.error.message}`);
} else if (event.type === 'run.completed' || event.type === 'run.failed') {
console.log(event.run.output);
}
}
Run every step from code
The three scripts below do everything on this page. setup_trip_agent creates the
knowledge base, the tool, the prompt and the agent. ask_trip_agent asks the question and
prints each step. teardown_trip_agent deletes all four, so you can run the setup again.
setup_trip_agent.py— Pythonask_trip_agent.py— Pythonteardown_trip_agent.py— Pythonsetup_trip_agent.mjs— Nodeask_trip_agent.mjs— Nodeteardown_trip_agent.mjs— Node
The setup script uses the models gpt-4o-mini and text-embedding-3-small. If yours have
other names, set CHAT_MODEL and EMBED_MODEL. Then run the scripts from the folder that holds
python/, typescript/ and data/:
export CHAT_MODEL=gpt-4o-mini EMBED_MODEL=text-embedding-3-small # your gateway's model names
python python/setup_trip_agent.py
python python/ask_trip_agent.py
Search 'a trip with snow': lapland-northern-lights.md (score 0.42)
Agent Trip planner (c6ba3e90-eae7-4bdd-a5a5-2f9fa766e84d)
Tools the model sees: ['search_trip_itineraries', 'get_trip_weather']
Q: I'd like a winter trip with snow. Which one do you have, what does it cost, and what is the weather like there right now?
step 1: model calls search_trip_itineraries({"query":"winter trip with snow"})
step 1: search_trip_itineraries -> ok=True
step 2: model calls get_trip_weather({"city":"Rovaniemi"})
step 2: get_trip_weather -> ok=True
A: I recommend the **Lapland northern lights** trip. Here are the details:
- **Season:** winter (December to March)
- **Price:** 1,450 EUR per person
**Current Weather in Rovaniemi:**
- Temperature: -9°C (feels like -13°C)
- Conditions: Light snow
Enjoy a magical winter experience!
status=succeeded trace=bf6b6798-2dc0-4939-9e94-bcc4bd716a27
The Node scripts take the same steps and print the same lines: node typescript/setup_trip_agent.mjs, then
node typescript/ask_trip_agent.mjs.
Next steps
- Rerank and filter an agent's search results adds a reranker and a decision model to the itinerary search.
- Let an agent count and filter a spreadsheet gives the agent the agency's bookings as a table it queries with SQL.
- Read the search steps of a RAG agent explains the search spans in the run's trace.
- Embed an agent on your website puts the agent on your site as a chat button.
- Version a prompt: commit a new system message and move
productionto it. The agent picks it up on its next run, with no change to the agent. - Connect a tool to a prompt covers pinning a tool version instead of following an alias.