Autonomer KI-Agent mit AWS, Bedrock und FastAPI gebaut, aber nicht ohne Aufsicht
Ein Entwickler beschreibt, wie ein Agent Informationen prüft, Schlüsse zieht und selbstständig handelt, und betont zugleich die Guardrails, die erofs unbeaufsichtigtes Handeln verhindern.

Exploring how autonomous AI agents can reason, use tools, and take action using AWS, Amazon Bedrock, and FastAPI — while keeping the right guardrails in place.
What happens when an AI agent is no longer limited to answering questions?
And, most importantly, it can take action.
That sounds exciting until you start thinking about what happens when the action is wrong.
That question led me to explore how autonomous AI agents can be built using AWS, Amazon Bedrock, FastAPI, and tool-based workflows.
I didn't want to build another chatbot that simply generates text.
I wanted to understand something more interesting:
Can we give an AI agent the ability to act while still keeping clear boundaries around what it is allowed to do?
That became the central idea behind this project.
A traditional chatbot usually follows a simple pattern:
User ↓ Prompt ↓ AI Model ↓ Response Enter fullscreen mode Exit fullscreen mode That's useful, but an AI agent can go much further.
An agent can receive a goal, reason about the situation, decide which tools it needs, use those tools, observe the results, and continue the workflow.
The architecture starts looking more like this:
User Request ↓ AI Agent ↓ Reasoning ↓ Choose Tool ↓ Execute Tool ↓ Observe Result ↓ Decide Next Step ↓ Response Enter fullscreen mode Exit fullscreen mode This is where AI becomes much more interesting to me.
The model isn't simply producing an answer.
And that introduces a completely different engineering question:
How much freedom should an AI agent actually have?
The visual shows the agent moving through understanding the goal, reasoning, selecting a tool, executing an action, observing the result, and continuing the loop.
I think the easiest way to understand an AI agent is to stop thinking of it as simply an LLM with a really good prompt.
An agent usually combines several pieces:
The model provides the intelligence, but the surrounding system gives that intelligence a way to interact with the world.
"Check whether a service is healthy and investigate if something looks unusual."
Instead of immediately generating a paragraph, the agent could reason through a sequence:
1. Understand the request 2. Identify the information required 3. Select an appropriate tool 4. Execute the tool 5. Inspect the result 6. Decide whether more information is needed 7. Produce a final response Enter fullscreen mode Exit fullscreen mode That's a very different interaction from a normal chatbot.
For the AI layer, I used Amazon Bedrock to work with foundation models through AWS.
What interested me most wasn't simply sending a prompt to a model.
I wanted the model to become part of an agent workflow.
A simplified architecture looks like this:
User │ ▼ FastAPI API │ ▼ AI Agent │ ┌─────────┴─────────┐ │ │ ▼ ▼ Amazon Bedrock Agent Tools │ │ └─────────┬─────────┘ ▼ AWS Services Enter fullscreen mode Exit fullscreen mode Amazon Bedrock becomes part of the model layer, while the application around it handles the workflow, tools, validation, and communication.
The foundation model doesn't need to be responsible for everything.
The application controls how the model is used.
This image gives readers a quick visual understanding of how the user request moves through FastAPI, the AI agent, Amazon Bedrock, and the tools/services layer.
I didn't want the agent to exist as a Python script that only worked from my development environment.
I wanted other applications to communicate with it through an API.
Client ↓ FastAPI ↓ AI Agent ↓ Amazon Bedrock ↓ Tools / AWS Services ↓ Result Enter fullscreen mode Exit fullscreen mode A simplified endpoint can look like this:
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI ( ) class AgentRequest ( BaseModel ): message: str @app. post ( "/agent" ) async def run_agent ( request: AgentRequest ): result = await run_agent_workflow ( request. message ) return { "status": "success", "result": result } Enter fullscreen mode Exit fullscreen mode The endpoint itself is simple.
Amazon Bedrock provides the model capability.
That separation makes the system easier to develop, test, and extend.
This was one of the most interesting parts of working with agents.
For example, an agent could have tools for:
The agent doesn't necessarily need to know how every tool works internally.
That creates a powerful interaction between AI reasoning and traditional software.
The agent can then decide what to do next.
This is one of the biggest differences between a chatbot and an agentic system.
This is where my thinking about autonomous AI changed.
"If the agent is intelligent enough, why not just let it perform the action?"
Because intelligence isn't the same thing as authorization.
An AI agent can misunderstand a request.
It can make a reasonable-looking decision that is still wrong.
And when an agent is connected to real systems, those mistakes can have real consequences.
AI ↓ Action Enter fullscreen mode Exit fullscreen mode I started thinking about:
AI Agent ↓ Reason ↓ Propose Action ↓ Validation ↓ Security Controls ↓ Approved? ↙ ↘ Yes No ↓ ↓ Action Block Enter fullscreen mode Exit fullscreen mode The important idea is simple:
The agent can help make a decision without automatically becoming the authority.
Giving an AI agent tools doesn't mean giving it unlimited permission.
Having a screwdriver, hammer, and drill doesn't mean you should use all three every time.
The same principle applies to AI agents.
An agent should have clearly defined capabilities.
These questions become increasingly important as agents move from demonstrations into real applications.
The visual should show the agent proposing an action, security validation checking it, and the action either being approved or rejected.
I think autonomy should be treated as a spectrum.
For some tasks, complete automation might make sense.
For other tasks, the AI could prepare an action but wait for approval.
For sensitive operations, the safest choice may be to block the action completely.
This distinction is easy to miss when building an AI agent.
Suppose an agent has access to five tools.
That doesn't mean every tool should be available for every request.
The agent might technically be able to call a tool, but the application should still determine whether that action is allowed.
AI Reasoning ↓ Tool Selection ↓ Input Validation ↓ Authorization ↓ Policy / Guardrail ↓ Execution ↓ Audit Enter fullscreen mode Exit fullscreen mode This is where traditional software engineering and AI engineering start overlapping.
But the application still needs to enforce boundaries.
One of the most interesting parts of agentic AI is the loop between reasoning and action.
┌──────────────┐ │ Goal │ └──────┬───────┘ ↓ ┌──────────────┐ │ Reason │ └──────┬───────┘ ↓ ┌──────────────┐ │ Select Tool │ └──────┬───────┘ ↓ ┌──────────────┐ │ Execute Tool │ └──────┬───────┘ ↓ ┌──────────────┐ │ Observe │ │ Result │ └──────┬───────┘ ↓ ┌──────────────┐ │ Reason Again │ └──────┬───────┘ │ └───────────► Enter fullscreen mode Exit fullscreen mode The agent can use the result of one operation to determine what should happen next.
That is where much of the power of agentic systems comes from.
It is also where much of the complexity comes from.
A simple prompt is relatively easy to reason about.
A system that can make several decisions and execute several tools requires much more careful engineering.
The biggest lesson wasn't about writing a FastAPI endpoint or connecting an LLM.
It was understanding that AI autonomy needs engineering around it.
When an AI only generates text, a bad response might simply be inaccurate or unhelpful.
When an AI can interact with systems, the consequences can be much larger.
That means an agent-based application needs more than prompts.
This is the part of agentic AI that I find most interesting.
The model is only one part of the system.
The architecture around the model determines how safely and reliably that intelligence can be used.
Once the agent is exposed through FastAPI, it becomes easier to think of it as a service rather than an isolated AI experiment.
POST / agent Enter fullscreen mode Exit fullscreen mode with something like:
{ "message": "Check the current system status" } Enter fullscreen mode Exit fullscreen mode The backend can then:
Receive Request ↓ Validate Input ↓ Run Agent ↓ Call Amazon Bedrock ↓ Select Tools ↓ Execute Allowed Actions ↓ Collect Results ↓ Return Response Enter fullscreen mode Exit fullscreen mode
This is a good place to show the actual API interaction, because readers have now seen the architecture and guardrail concepts and can finally see what the API looks like in practice.
I don't think the next generation of AI applications will all look like chat windows.
We're going to see more applications where AI works in the background.
That's much closer to having an intelligent software worker than having a chatbot.
But the more capable these systems become, the more important boundaries become.
When I started experimenting with AI agents, my main question was:
After working through the architecture, my question changed.
"How do we let an AI take useful actions without giving it unlimited control?"
I think that's one of the most interesting engineering problems around agentic AI.
The future probably isn't about choosing between humans and autonomous AI.
It may be about designing systems where:
Humans remain in control of decisions that matter most.
And that's the direction I want to keep exploring.
If you're building AI agents too, I'd love to hear what you're experimenting with — especially how you're deciding what your agents should and shouldn't be allowed to do.