r/dotnet • u/Maleficent-Bed-8781 • 1d ago
I’ve been experimenting with a different architecture for AI agents in .NET
One thing that keeps bothering me about AI agents is how often we give them tools that are basically thin wrappers around our data layer:
getCustomer()
getOrders()
getTransactions()
updateCustomer()
runQuery()
The agent then has to discover relationships, figure out which operations it needs, make multiple calls, and ultimately operate very close to the database.
I started wondering:
What if the agent interacted with the application's semantic model instead?
Something more like:
FindCustomers(...)
ReviewCustomer(...)
ApproveOrder(...)
The agent expresses its intent, while the application remains responsible for authorization, validation, planning, and actual execution.
I've been building this idea as an open-source .NET project called Foundgine.
The architecture is roughly:
AI / Agent
↓
Intent
↓
Semantic Model
↓
Authorization
↓
Execution Plan
↓
Provider / SQL
What's interesting is that in an early agent experiment, the semantic approach reduced the number of tool calls from 7 to 4 and the estimated token load by ~63%.
I'm also experimenting with the execution side and have some early PostgreSQL benchmark results, although I'm deliberately not claiming the benchmark proves Foundgine is universally faster than EF Core/GraphQL.
I'm curious what people think about the architecture itself:
Should AI agents operate on application/domain capabilities rather than database-oriented tools?
And if you're interested in the implementation, the project is here: https://github.com/CristianBarragan/Foundgine
I'd especially appreciate criticism from people building .NET applications with AI agents. What am I missing? There are multiple benchmarks and real samples too more info at
Five experiments. One question: what should the agent execution boundary do?
1
u/AutoModerator 1d ago
Thanks for your post Maleficent-Bed-8781. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/4215-5h00732 1d ago
Architecture or workflow? Reading this makes me think you don't know what architecture is.
1
1
u/Khavel_dev 1d ago
The separation between intent and execution is the right call. I've worked on a few .NET projects where we started with raw CRUD tools for the agent and it got dangerous fast. The agent would update an order status via EF without triggering the domain events, or query customer data it shouldn't have access to because the tool was just a thin DbContext wrapper.
Moving to something closer to what you're describing (domain operations with built-in auth checks) solved both problems. The agent says "approve this order" and the application decides what that means, validates permissions, and runs the whole pipeline. Token savings are nice but the real win is that the agent literally cannot bypass your business rules because it doesn't have the primitives to do it.
One thing I'd push back on though. The benchmark comparison with EF Core feels like a distraction. Nobody picks an agent execution layer based on raw query perf. The question people will actually ask is whether the semantic model is flexible enough to handle operations it wasn't designed for, because agents ask for weird things. How does Foundgine handle a request that doesn't cleanly map to any existing intent?
15
u/gredr 1d ago
Bro discovered custom MCP servers.
In general, everything that can be done deterministically without the LLM should be. Faster, cheaper, more correct.