Pinned Tweet
Last week I released the first article in my hands-on ๐—•๐˜‚๐—ถ๐—น๐—ฑ๐—ถ๐—ป๐—ด ๐—”๐—œ ๐—”๐—ด๐—ฒ๐—ป๐˜๐˜€ ๐—™๐—ฟ๐—ผ๐—บ ๐—ฆ๐—ฐ๐—ฟ๐—ฎ๐˜๐—ฐ๐—ต series. It covers the tool use element of an Agent.

I wanted to do this for quite some time now and finally the time has arrived!

If you are using any orchestration applications, you might be abstracted away from what using a tool really means. I believe that understanding applications from the base building blocks is really important so we are implementing all of the abstractions from scratch.

After finishing the project you will learn:
โžก๏ธ What AI Agents are.
โžก๏ธ How the Tool usage in AI Agents actually works.
โžก๏ธ How to build a decorator wrapper that extracts relevant details from a Python function to be passed to the LLM via system prompt.
โžก๏ธ How to think about constructing effective system prompts that can be used for Agents.
โžก๏ธ How to build an Agent class that is able to plan and execute actions using provided Tools.

You can find the article here: newsletter.swirlai.com/p/building-ai-โ€ฆ

You can also find a Jupyter notebook and python scripts that complement the article in a GitHub repo (links in the article).

Youtube videos coming soon!

If youโ€™re looking for something to dig your hands into between holidays be sure to take a look!

Second part of the series is coming in a few weeks.

Let me know if there are any issues following the project. Feel free to DM me or leave comments here or under the article ๐Ÿ‘‡

#AI #LLM #MachineLearning
38
198
1,155
98,861
Aurimas Griciลซnas retweeted
This is how you measure your AI system as an AI Engineer ๐Ÿ‘‡

For regular software you would track metrics like uptime, error rate, p95 latency. However, they say little about whether the system is fast where users feel it, affordable at scale or correct.

Here are the metrics we systems. It is useful to group them by the question they answer:

๐Ÿญ. ๐—œ๐˜€ ๐—ถ๐˜ ๐—ณ๐—ฎ๐˜€๐˜? (๐—Ÿ๐—ฎ๐˜๐—ฒ๐—ป๐—ฐ๐˜†)

โžก๏ธ Time to first token (TTFT): how long the user is exposed to a blank screen, the number that defines perceived latency.
โžก๏ธ Inter-token latency (ITL): how smoothly tokens stream after the first one.
โžก๏ธ End-to-end latency at p50 / p95 / p99, dominated by output length, track it per use case rather than globally.

๐Ÿฎ. ๐—–๐—ฎ๐—ป ๐—ถ๐˜ ๐˜€๐—ฐ๐—ฎ๐—น๐—ฒ? (๐—ง๐—ต๐—ฟ๐—ผ๐˜‚๐—ด๐—ต๐—ฝ๐˜‚๐˜ ๐—ฎ๐—ป๐—ฑ ๐—ฐ๐—ผ๐˜€๐˜)

โžก๏ธ Tokens per second per user vs total system throughput, the two trade off against each other on the same hardware.
โžก๏ธ Input and output tokens per request to measure your unit economics.
โžก๏ธ Cache hit rate - prompt caching is often the technique that reduces cost the most.
โžก๏ธ Cost per successful task, not cost per request, a cheap request that fails is a waste.

๐Ÿฏ. ๐—œ๐˜€ ๐—ถ๐˜ ๐—ฐ๐—ผ๐—ฟ๐—ฟ๐—ฒ๐—ฐ๐˜? (๐—ค๐˜‚๐—ฎ๐—น๐—ถ๐˜๐˜†)

โžก๏ธ Task success rate on a labeled eval set, re-run on every prompt or model change.
โžก๏ธ Groundedness for RAG - is the answer supported by the retrieved context.
โžก๏ธ Retrieval precision@k and recall@k - generation cannot fix what retrieval never surfaced.
โžก๏ธ LLM-as-judge scores over time, calibrated against human labels.
โžก๏ธ User feedback signals: thumbs, edits to generated output, free form feedback.

๐Ÿฐ. ๐——๐—ผ๐—ฒ๐˜€ ๐—ถ๐˜ ๐—ต๐—ผ๐—น๐—ฑ ๐˜‚๐—ฝ? (๐—ฅ๐—ฒ๐—น๐—ถ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†)

โžก๏ธ Error, timeout and rate-limit rates per provider.
โžก๏ธ Retry and fallback rate - how often you silently switch to a backup model.
โžก๏ธ Guardrail trigger and refusal rates.

๐Ÿฑ. ๐—›๐—ผ๐˜„ ๐—ฑ๐—ผ๐—ฒ๐˜€ ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฎ๐—ด๐—ฒ๐—ป๐˜ ๐—ฏ๐—ฒ๐—ต๐—ฎ๐˜ƒ๐—ฒ? (๐—”๐—ด๐—ฒ๐—ป๐˜ ๐—บ๐—ฒ๐˜๐—ฟ๐—ถ๐—ฐ๐˜€)

โžก๏ธ Tool-call error rate.
โžก๏ธ Steps and tokens per completed task - drift here means cost is rising while accuracy remains the same
โžก๏ธ Context window utilization - the early warning for compaction and truncation issues.

โ—๏ธ Latency and reliability show up on day one because standard infra emits them. Quality, cost per task, and agent behavior need deliberate instrumentation, and they are where AI systems fail in production.

Which metric caught a real problem for you that the standard dashboards missed? ๐Ÿ‘‡
15
2
26
1,597
This is how you measure your AI system as an AI Engineer ๐Ÿ‘‡

For regular software you would track metrics like uptime, error rate, p95 latency. However, they say little about whether the system is fast where users feel it, affordable at scale or correct.

Here are the metrics we systems. It is useful to group them by the question they answer:

๐Ÿญ. ๐—œ๐˜€ ๐—ถ๐˜ ๐—ณ๐—ฎ๐˜€๐˜? (๐—Ÿ๐—ฎ๐˜๐—ฒ๐—ป๐—ฐ๐˜†)

โžก๏ธ Time to first token (TTFT): how long the user is exposed to a blank screen, the number that defines perceived latency.
โžก๏ธ Inter-token latency (ITL): how smoothly tokens stream after the first one.
โžก๏ธ End-to-end latency at p50 / p95 / p99, dominated by output length, track it per use case rather than globally.

๐Ÿฎ. ๐—–๐—ฎ๐—ป ๐—ถ๐˜ ๐˜€๐—ฐ๐—ฎ๐—น๐—ฒ? (๐—ง๐—ต๐—ฟ๐—ผ๐˜‚๐—ด๐—ต๐—ฝ๐˜‚๐˜ ๐—ฎ๐—ป๐—ฑ ๐—ฐ๐—ผ๐˜€๐˜)

โžก๏ธ Tokens per second per user vs total system throughput, the two trade off against each other on the same hardware.
โžก๏ธ Input and output tokens per request to measure your unit economics.
โžก๏ธ Cache hit rate - prompt caching is often the technique that reduces cost the most.
โžก๏ธ Cost per successful task, not cost per request, a cheap request that fails is a waste.

๐Ÿฏ. ๐—œ๐˜€ ๐—ถ๐˜ ๐—ฐ๐—ผ๐—ฟ๐—ฟ๐—ฒ๐—ฐ๐˜? (๐—ค๐˜‚๐—ฎ๐—น๐—ถ๐˜๐˜†)

โžก๏ธ Task success rate on a labeled eval set, re-run on every prompt or model change.
โžก๏ธ Groundedness for RAG - is the answer supported by the retrieved context.
โžก๏ธ Retrieval precision@k and recall@k - generation cannot fix what retrieval never surfaced.
โžก๏ธ LLM-as-judge scores over time, calibrated against human labels.
โžก๏ธ User feedback signals: thumbs, edits to generated output, free form feedback.

๐Ÿฐ. ๐——๐—ผ๐—ฒ๐˜€ ๐—ถ๐˜ ๐—ต๐—ผ๐—น๐—ฑ ๐˜‚๐—ฝ? (๐—ฅ๐—ฒ๐—น๐—ถ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜†)

โžก๏ธ Error, timeout and rate-limit rates per provider.
โžก๏ธ Retry and fallback rate - how often you silently switch to a backup model.
โžก๏ธ Guardrail trigger and refusal rates.

๐Ÿฑ. ๐—›๐—ผ๐˜„ ๐—ฑ๐—ผ๐—ฒ๐˜€ ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฎ๐—ด๐—ฒ๐—ป๐˜ ๐—ฏ๐—ฒ๐—ต๐—ฎ๐˜ƒ๐—ฒ? (๐—”๐—ด๐—ฒ๐—ป๐˜ ๐—บ๐—ฒ๐˜๐—ฟ๐—ถ๐—ฐ๐˜€)

โžก๏ธ Tool-call error rate.
โžก๏ธ Steps and tokens per completed task - drift here means cost is rising while accuracy remains the same
โžก๏ธ Context window utilization - the early warning for compaction and truncation issues.

โ—๏ธ Latency and reliability show up on day one because standard infra emits them. Quality, cost per task, and agent behavior need deliberate instrumentation, and they are where AI systems fail in production.

Which metric caught a real problem for you that the standard dashboards missed? ๐Ÿ‘‡
15
2
26
1,597
Aurimas Griciลซnas retweeted
๐—ก๐—ถ๐—ป๐—ฒ ๐—ฝ๐—น๐—ฎ๐—ฐ๐—ฒ๐˜€ ๐˜๐—ผ ๐˜‚๐˜€๐—ฒ ๐——๐—ฒ๐—ฐ๐—ถ๐˜€๐—ถ๐—ผ๐—ป ๐— ๐—ผ๐—ฑ๐—ฒ๐—น๐˜€ (๐—๐—ฒ๐˜ƒ) ๐—ถ๐—ป ๐—”๐—ด๐—ฒ๐—ป๐˜๐—ถ๐—ฐ ๐—ฅ๐—”๐—š ๐˜€๐˜†๐˜€๐˜๐—ฒ๐—บ front to back ๐Ÿ‘‡

๐Ÿญ. ๐— ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ฟ๐—ผ๐˜‚๐˜๐—ถ๐—ป๐—ด. The prompt goes to a decision model, it picks the tier. Cheap models for lookups, expensive for what you cannot afford ๐—ฎ๐—ถ๐—น๐˜€. A separate yes-or-no per potential hazard. Before the LLM sees the input or on the answer that has been produced.
๐Ÿฏ. ๐—ฅ๐—ฒ๐˜๐—ฟ๐—ถ๐—ฒ๐˜ƒ๐—ฎ๐—น ๐˜€๐˜‚๐—ณ๐—ณ๐—ถ๐—ฐ๐—ถ๐—ฒ๐—ป๐—ฐ๐˜†. Is what came back enough to answer, or should we search again.
๐Ÿฐ. ๐—ฃ๐—ฎ๐˜€๐˜€๐—ฎ๐—ด๐—ฒ ๐—ณ๐—ถ๐—น๐˜๐—ฒ๐—ฟ๐—ถ๐—ป๐—ด ๐—ฎ๐—ป๐—ฑ ๐—ฟ๐—ฒ๐—ฟ๐—ฎ๐—ป๐—ธ๐—ถ๐—ป๐—ด. Does this passage answer the question or is it only keyword-adjacent. Apply per candidate and sort by probability.
๐Ÿฑ. ๐—–๐—ถ๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฐ๐—ต๐—ฒ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด. Does this source support the claim, contradict it, or fail to address it.
๐Ÿฒ. ๐—ง๐—ผ๐—ผ๐—น-๐—ฐ๐—ฎ๐—น๐—น ๐—ด๐—ฎ๐˜๐—ถ๐—ป๐—ด. Allow, ask or deny per call, with the bands in your code.
๐Ÿณ. ๐—Ÿ๐—ผ๐—ผ๐—ฝ ๐˜๐—ฒ๐—ฟ๐—บ๐—ถ๐—ป๐—ฎ๐˜๐—ถ๐—ผ๐—ป. Does the result actually satisfy the acceptance criteria?
๐Ÿด. ๐—–๐—ผ๐—ป๐˜๐—ฒ๐˜…๐˜ ๐—ฐ๐—ผ๐—บ๐—ฝ๐—ฎ๐—ฐ๐˜๐—ถ๐—ผ๐—ป. Score each piece of context and drop the stale ones instead of summarising them.
๐Ÿต. ๐—˜๐˜ƒ๐—ฎ๐—น๐˜€ ๐—ฎ๐˜ ๐—ณ๐˜‚๐—น๐—น ๐—ฐ๐—ผ๐˜ƒ๐—ฒ๐—ฟ๐—ฎ๐—ด๐—ฒ. Significantly cheaper per verdict than an LLM judge. Potentially unlocks the ability to grade every trace instead of sampling.

Outside the Agentic RAG loop there are so many other use cases:

โžก๏ธ Bulk labeling.
โžก๏ธ Inbox triage.
โžก๏ธ Secret detection in diffs.
โžก๏ธ โ€ฆ

What to watch out for:

โŒ You still need to eval your decision model use.
โŒ Closely monitor your thresholds and version them as code.
โŒ Decision models do not return an explanation, only which outputs are bad. If you require an explanation, fall back to an LLM judge.

๐Ÿ‘‰ Generation is one call in most systems. The decisions around it are the other twenty, and that is where this pays.

What else belongs on the list? ๐Ÿ‘‡
18
24
135
4,903
๐—ก๐—ถ๐—ป๐—ฒ ๐—ฝ๐—น๐—ฎ๐—ฐ๐—ฒ๐˜€ ๐˜๐—ผ ๐˜‚๐˜€๐—ฒ ๐——๐—ฒ๐—ฐ๐—ถ๐˜€๐—ถ๐—ผ๐—ป ๐— ๐—ผ๐—ฑ๐—ฒ๐—น๐˜€ (๐—๐—ฒ๐˜ƒ) ๐—ถ๐—ป ๐—”๐—ด๐—ฒ๐—ป๐˜๐—ถ๐—ฐ ๐—ฅ๐—”๐—š ๐˜€๐˜†๐˜€๐˜๐—ฒ๐—บ front to back ๐Ÿ‘‡

๐Ÿญ. ๐— ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ฟ๐—ผ๐˜‚๐˜๐—ถ๐—ป๐—ด. The prompt goes to a decision model, it picks the tier. Cheap models for lookups, expensive for what you cannot afford ๐—ฎ๐—ถ๐—น๐˜€. A separate yes-or-no per potential hazard. Before the LLM sees the input or on the answer that has been produced.
๐Ÿฏ. ๐—ฅ๐—ฒ๐˜๐—ฟ๐—ถ๐—ฒ๐˜ƒ๐—ฎ๐—น ๐˜€๐˜‚๐—ณ๐—ณ๐—ถ๐—ฐ๐—ถ๐—ฒ๐—ป๐—ฐ๐˜†. Is what came back enough to answer, or should we search again.
๐Ÿฐ. ๐—ฃ๐—ฎ๐˜€๐˜€๐—ฎ๐—ด๐—ฒ ๐—ณ๐—ถ๐—น๐˜๐—ฒ๐—ฟ๐—ถ๐—ป๐—ด ๐—ฎ๐—ป๐—ฑ ๐—ฟ๐—ฒ๐—ฟ๐—ฎ๐—ป๐—ธ๐—ถ๐—ป๐—ด. Does this passage answer the question or is it only keyword-adjacent. Apply per candidate and sort by probability.
๐Ÿฑ. ๐—–๐—ถ๐˜๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ฐ๐—ต๐—ฒ๐—ฐ๐—ธ๐—ถ๐—ป๐—ด. Does this source support the claim, contradict it, or fail to address it.
๐Ÿฒ. ๐—ง๐—ผ๐—ผ๐—น-๐—ฐ๐—ฎ๐—น๐—น ๐—ด๐—ฎ๐˜๐—ถ๐—ป๐—ด. Allow, ask or deny per call, with the bands in your code.
๐Ÿณ. ๐—Ÿ๐—ผ๐—ผ๐—ฝ ๐˜๐—ฒ๐—ฟ๐—บ๐—ถ๐—ป๐—ฎ๐˜๐—ถ๐—ผ๐—ป. Does the result actually satisfy the acceptance criteria?
๐Ÿด. ๐—–๐—ผ๐—ป๐˜๐—ฒ๐˜…๐˜ ๐—ฐ๐—ผ๐—บ๐—ฝ๐—ฎ๐—ฐ๐˜๐—ถ๐—ผ๐—ป. Score each piece of context and drop the stale ones instead of summarising them.
๐Ÿต. ๐—˜๐˜ƒ๐—ฎ๐—น๐˜€ ๐—ฎ๐˜ ๐—ณ๐˜‚๐—น๐—น ๐—ฐ๐—ผ๐˜ƒ๐—ฒ๐—ฟ๐—ฎ๐—ด๐—ฒ. Significantly cheaper per verdict than an LLM judge. Potentially unlocks the ability to grade every trace instead of sampling.

Outside the Agentic RAG loop there are so many other use cases:

โžก๏ธ Bulk labeling.
โžก๏ธ Inbox triage.
โžก๏ธ Secret detection in diffs.
โžก๏ธ โ€ฆ

What to watch out for:

โŒ You still need to eval your decision model use.
โŒ Closely monitor your thresholds and version them as code.
โŒ Decision models do not return an explanation, only which outputs are bad. If you require an explanation, fall back to an LLM judge.

๐Ÿ‘‰ Generation is one call in most systems. The decisions around it are the other twenty, and that is where this pays.

What else belongs on the list? ๐Ÿ‘‡
18
24
135
4,903
Aurimas Griciลซnas retweeted
๐—–๐˜‚๐˜๐˜๐—ถ๐—ป๐—ด ๐—ฎ๐—ป ๐—”๐—œ ๐—ฏ๐—ถ๐—น๐—น ๐˜‚๐˜€๐˜‚๐—ฎ๐—น๐—น๐˜† ๐˜€๐˜๐—ฎ๐—ฟ๐˜๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ผ๐—ธ๐—ฒ๐—ป ๐—ฐ๐—ฎ๐—ฝ๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ฐ๐—ต๐—ฒ๐—ฎ๐—ฝ๐—ฒ๐—ฟ ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น๐˜€, ๐˜„๐—ต๐—ถ๐—ฐ๐—ต ๐—น๐—ผ๐˜„๐—ฒ๐—ฟ๐˜€ ๐˜๐—ต๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜ ๐—พ๐˜‚๐—ฎ๐—น๐—ถ๐˜๐˜† ๐—ฎ๐—น๐—ผ๐—ป๐—ด ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ต๐—ฒ ๐˜€๐—ฝ๐—ฒ๐—ป๐—ฑ.

There is a different place to look at first. In most share of the cost comes from the work the system has already done and is paying for again:

โžก๏ธ The same question arrives in different words, so an exact-match cache never sees it and the model answers it from scratch every time
โžก๏ธ The agent drops context between turns and sessions, so it re-retrieves what it had and asks the user for what it was already told
โžก๏ธ All of that state, cache entries, session history, memory vectors, features, has to stay fast, and memory is the most expensive thing in the rack

None of those are model problems. They are caching, memory and storage decisions, which is the part of an AI system that gets the least design attention and ramps up the spend significantly.

I have been reading through how Redis approaches this. They offer three mechanisms that tackle the above problems in a single platform:

โœ… Semantic caching: embed the incoming prompt, search prior prompts by meaning, and serve the stored response when it is close enough. Redis reports cache hits up to 15x faster and token spend down by up to 70%
โœ… Agent memory: live session state with a TTL, plus facts extracted out of conversations into long-term memory as vectors, with the extraction running in the background instead of in the request (hot) path
โœ… Flex: one database moving both keys and values between RAM and NVMe SSD storage tiers. You can adjust RAM ratio 10% and 50% per workload. Redis states this costs up to 80% less per gigabyte than running all-RAM, with no code change

The part I find interesting is that memory architecture is usually treated as a quality feature, something that makes the agent feel coherent. It is also a cost lever - an agent that forgets incurs the price twice for the same context.

๐Ÿ‘‰ Here is their cost optimisation guide: fandf.co/3TVKDxt

Huge shoutout to @Redisinc for partnering on this post!

What share of your production traffic is a repeat of a question you have already answered? I rarely run into a team that is actually measuring this! ๐Ÿ‘‡
11
9
42
2,385
๐—–๐˜‚๐˜๐˜๐—ถ๐—ป๐—ด ๐—ฎ๐—ป ๐—”๐—œ ๐—ฏ๐—ถ๐—น๐—น ๐˜‚๐˜€๐˜‚๐—ฎ๐—น๐—น๐˜† ๐˜€๐˜๐—ฎ๐—ฟ๐˜๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ผ๐—ธ๐—ฒ๐—ป ๐—ฐ๐—ฎ๐—ฝ๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ฐ๐—ต๐—ฒ๐—ฎ๐—ฝ๐—ฒ๐—ฟ ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น๐˜€, ๐˜„๐—ต๐—ถ๐—ฐ๐—ต ๐—น๐—ผ๐˜„๐—ฒ๐—ฟ๐˜€ ๐˜๐—ต๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜ ๐—พ๐˜‚๐—ฎ๐—น๐—ถ๐˜๐˜† ๐—ฎ๐—น๐—ผ๐—ป๐—ด ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ต๐—ฒ ๐˜€๐—ฝ๐—ฒ๐—ป๐—ฑ.

There is a different place to look at first. In most share of the cost comes from the work the system has already done and is paying for again:

โžก๏ธ The same question arrives in different words, so an exact-match cache never sees it and the model answers it from scratch every time
โžก๏ธ The agent drops context between turns and sessions, so it re-retrieves what it had and asks the user for what it was already told
โžก๏ธ All of that state, cache entries, session history, memory vectors, features, has to stay fast, and memory is the most expensive thing in the rack

None of those are model problems. They are caching, memory and storage decisions, which is the part of an AI system that gets the least design attention and ramps up the spend significantly.

I have been reading through how Redis approaches this. They offer three mechanisms that tackle the above problems in a single platform:

โœ… Semantic caching: embed the incoming prompt, search prior prompts by meaning, and serve the stored response when it is close enough. Redis reports cache hits up to 15x faster and token spend down by up to 70%
โœ… Agent memory: live session state with a TTL, plus facts extracted out of conversations into long-term memory as vectors, with the extraction running in the background instead of in the request (hot) path
โœ… Flex: one database moving both keys and values between RAM and NVMe SSD storage tiers. You can adjust RAM ratio 10% and 50% per workload. Redis states this costs up to 80% less per gigabyte than running all-RAM, with no code change

The part I find interesting is that memory architecture is usually treated as a quality feature, something that makes the agent feel coherent. It is also a cost lever - an agent that forgets incurs the price twice for the same context.

๐Ÿ‘‰ Here is their cost optimisation guide: fandf.co/3TVKDxt

Huge shoutout to @Redisinc for partnering on this post!

What share of your production traffic is a repeat of a question you have already answered? I rarely run into a team that is actually measuring this! ๐Ÿ‘‡
11
9
42
2,385
Aurimas Griciลซnas retweeted
๐—ง๐—ผ๐—ผ๐—น ๐—–๐—ฎ๐—น๐—น๐—ถ๐—ป๐—ด ๐˜ƒ๐—ถ๐—ฎ ๐— ๐—–๐—ฃ vs. implementing it ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐˜๐—ผ ๐˜๐—ต๐—ฒ ๐—”๐—ด๐—ฒ๐—ป๐˜. What's the difference?

Recently there have been many MCP vs. Function Calling articles floating around. Letโ€™s simplify.

โ—๏ธ ๐—–๐—น๐—ฎ๐—ฟ๐—ถ๐—ณ๐˜†๐—ถ๐—ป๐—ด ๐—ผ๐—ป๐—ฒ ๐—ฑ๐—ฒ๐˜๐—ฎ๐—ถ๐—น: Function Calling Systems are almost the same thing. You can implement tools via functions, the only difference is that functions are usually used to enforce stricter structure to the input and output schema.

๐˜œ๐˜ด๐˜ช๐˜ฏ๐˜จ ๐˜”๐˜Š๐˜— ๐˜ต๐˜ฐ ๐˜ฆ๐˜น๐˜ฑ๐˜ฐ๐˜ด๐˜ฆ ๐˜ต๐˜ฐ๐˜ฐ๐˜ญ๐˜ด ๐˜ต๐˜ฐ ๐˜บ๐˜ฐ๐˜ถ๐˜ณ ๐˜ˆ๐˜จ๐˜ฆ๐˜ฏ๐˜ต๐˜ด:

โ„น๏ธ In this case your Agent becomes an MCP Host and implements one or more MCP Clients to communicate with MCP Servers.

๐Ÿญ. User Query is passed to the Agent (usually a Python application).
๐Ÿฎ. The application implements MCP Client and via it retrieves all available tools from the MCP servers.
๐Ÿฏ. The list of available Tools is passed together with the User Query to a LLM via a prompt. The LLM figures out which tools need to be invoked and with what parameters.
๐Ÿฐ. The Agent application communicates with the MCP server (via MCP Client) again and sends the tool execution request. After execution completes the Agent receives the required data.
๐Ÿฑ. User Query is sent to the LLM together with the data retrieved by the Tool calls.
๐Ÿฒ. The answer is constructed and returned to the user via the Agent.

๐˜œ๐˜ด๐˜ช๐˜ฏ๐˜จ ๐˜•๐˜ข๐˜ต๐˜ช๐˜ท๐˜ฆ ๐˜๐˜ถ๐˜ฏ๐˜ค๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜Š๐˜ข๐˜ญ๐˜ญ๐˜ช๐˜ฏ๐˜จ:

๐Ÿญ. User Query is passed to the Agent (usually a Python application).
๐Ÿฎ. All of the available Functions/Tools are defined as part of the Agent code (procedural memory).
๐Ÿฏ. The list of available Tools is passed together with the User Query to a LLM via a prompt. The LLM figures out which functions need to be invoked and with what parameters.
๐Ÿฐ. The Agent application directly executes the functions.
๐Ÿฑ. User Query is sent to the LLM together with the data retrieved after function execution.
๐Ÿฒ. The answer is constructed and returned to the user via the Agent.

๐— ๐˜† ๐˜๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€:

โ—๏ธ From the trenches, it looks like we have place for both methods of tool calling, only standardise behind MCP servers if necessary.
โ—๏ธ I see more practitioners abandoning MCP due to the lack of flexibility and additional failure points.

Are you using MCP already to expose Tools to your Agents? Let me know in the comments. ๐Ÿ‘‡
20
5
64
3,561
๐—ง๐—ผ๐—ผ๐—น ๐—–๐—ฎ๐—น๐—น๐—ถ๐—ป๐—ด ๐˜ƒ๐—ถ๐—ฎ ๐— ๐—–๐—ฃ vs. implementing it ๐—ก๐—ฎ๐˜๐—ถ๐˜ƒ๐—ฒ ๐˜๐—ผ ๐˜๐—ต๐—ฒ ๐—”๐—ด๐—ฒ๐—ป๐˜. What's the difference?

Recently there have been many MCP vs. Function Calling articles floating around. Letโ€™s simplify.

โ—๏ธ ๐—–๐—น๐—ฎ๐—ฟ๐—ถ๐—ณ๐˜†๐—ถ๐—ป๐—ด ๐—ผ๐—ป๐—ฒ ๐—ฑ๐—ฒ๐˜๐—ฎ๐—ถ๐—น: Function Calling Systems are almost the same thing. You can implement tools via functions, the only difference is that functions are usually used to enforce stricter structure to the input and output schema.

๐˜œ๐˜ด๐˜ช๐˜ฏ๐˜จ ๐˜”๐˜Š๐˜— ๐˜ต๐˜ฐ ๐˜ฆ๐˜น๐˜ฑ๐˜ฐ๐˜ด๐˜ฆ ๐˜ต๐˜ฐ๐˜ฐ๐˜ญ๐˜ด ๐˜ต๐˜ฐ ๐˜บ๐˜ฐ๐˜ถ๐˜ณ ๐˜ˆ๐˜จ๐˜ฆ๐˜ฏ๐˜ต๐˜ด:

โ„น๏ธ In this case your Agent becomes an MCP Host and implements one or more MCP Clients to communicate with MCP Servers.

๐Ÿญ. User Query is passed to the Agent (usually a Python application).
๐Ÿฎ. The application implements MCP Client and via it retrieves all available tools from the MCP servers.
๐Ÿฏ. The list of available Tools is passed together with the User Query to a LLM via a prompt. The LLM figures out which tools need to be invoked and with what parameters.
๐Ÿฐ. The Agent application communicates with the MCP server (via MCP Client) again and sends the tool execution request. After execution completes the Agent receives the required data.
๐Ÿฑ. User Query is sent to the LLM together with the data retrieved by the Tool calls.
๐Ÿฒ. The answer is constructed and returned to the user via the Agent.

๐˜œ๐˜ด๐˜ช๐˜ฏ๐˜จ ๐˜•๐˜ข๐˜ต๐˜ช๐˜ท๐˜ฆ ๐˜๐˜ถ๐˜ฏ๐˜ค๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜Š๐˜ข๐˜ญ๐˜ญ๐˜ช๐˜ฏ๐˜จ:

๐Ÿญ. User Query is passed to the Agent (usually a Python application).
๐Ÿฎ. All of the available Functions/Tools are defined as part of the Agent code (procedural memory).
๐Ÿฏ. The list of available Tools is passed together with the User Query to a LLM via a prompt. The LLM figures out which functions need to be invoked and with what parameters.
๐Ÿฐ. The Agent application directly executes the functions.
๐Ÿฑ. User Query is sent to the LLM together with the data retrieved after function execution.
๐Ÿฒ. The answer is constructed and returned to the user via the Agent.

๐— ๐˜† ๐˜๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€:

โ—๏ธ From the trenches, it looks like we have place for both methods of tool calling, only standardise behind MCP servers if necessary.
โ—๏ธ I see more practitioners abandoning MCP due to the lack of flexibility and additional failure points.

Are you using MCP already to expose Tools to your Agents? Let me know in the comments. ๐Ÿ‘‡
20
5
64
3,561
Aurimas Griciลซnas retweeted
๐——๐—ฒ๐—ฐ๐—ถ๐˜€๐—ถ๐—ผ๐—ป ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น๐˜€ (๐—๐—ฒ๐˜ƒ ๐—ฏ๐—ฒ๐—ถ๐—ป๐—ด ๐—ผ๐—ป๐—ฒ ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ๐—บ) ๐˜€๐—ต๐—ถ๐—ฝ๐—ฝ๐—ฒ๐—ฑ ๐—ฎ๐˜€ ๐—ฎ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜ ๐—ฐ๐—ฎ๐˜๐—ฒ๐—ด๐—ผ๐—ฟ๐˜† ๐—น๐—ฎ๐˜€๐˜ ๐—บ๐—ผ๐—ป๐˜๐—ต. Here is why they are different to LLMs even though both can achieve the same result ๐Ÿ‘‡

In decision models, you pass state, text or ose answers you declare in code. You get back a probability over those answers. Thatโ€™s it, and it is also the selling point, nothing to parse and validate.

On the other hand, asking an LLM for a bounded answer means:

๐Ÿญ. Option list and rubric go in the prompt
๐Ÿฎ. The model generates tokens, one forward pass each
๐Ÿฏ. You parse the string, validate the schema, retry on invalidation
๐Ÿฐ. The answer set is enforced after the text already exists

A decision model on the other hand makes the answer space an input, bounded before inference runs. With one scoring pass, you get a probability for every option you declare. Basically, a typed value with confidence attached.

Pros:

โœ… You get a distribution, not a label. Per-option probability allows you to write the decision policy once: act above a threshold, cheap second check in the middle band, escalate the tail.
โœ… Latency that significantly reduces the total latency of the loop. Jev runs P50 at 0.21 s and P95 at 0.34 s, and OpenAI advertises Decisions API to be close to 150 ms against roughly 1.6 s for the same model answering normally.
โœ… No cost on the output side. Jev is $0.042 per million input tokens with free output. Generally, output is the expensive half of a judgment.

What to be aware of:

โŒ Calibrated is a vendor claim. Check it against your own labelled set calibrate thresholds in house.
โŒ Accuracy degrades as irrelevant state grows. As always, keep your context as lean as possible.
โŒ Option names are more important for Decision Heads than the rubrics explaining them. Make sure to name them accordingly. I.e. refund_full_no_return instead of option_a.

๐Ÿ‘‰ Count the model calls in your agent loop, e.g.:

โžก๏ธ Routing
โžก๏ธ Is the retrieved context sufficient
โžก๏ธ Is the draft grounded
โžก๏ธ Do we escalate

All of these have finite answer sets and run as full LLM calls with schema on top today. However, only one really needs to generate some text.

โ—๏ธ There is still a lot of use case for complex structure outputs, not every problem can be solved with simple classifiers.

Looking forward to seeing decision models proliferate in architectures our clients are building!

Which decisions in your system are a full LLM call that did not need to be? ๐Ÿ‘‡
3
3
14
1,243
๐——๐—ฒ๐—ฐ๐—ถ๐˜€๐—ถ๐—ผ๐—ป ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น๐˜€ (๐—๐—ฒ๐˜ƒ ๐—ฏ๐—ฒ๐—ถ๐—ป๐—ด ๐—ผ๐—ป๐—ฒ ๐—ผ๐—ณ ๐˜๐—ต๐—ฒ๐—บ) ๐˜€๐—ต๐—ถ๐—ฝ๐—ฝ๐—ฒ๐—ฑ ๐—ฎ๐˜€ ๐—ฎ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜ ๐—ฐ๐—ฎ๐˜๐—ฒ๐—ด๐—ผ๐—ฟ๐˜† ๐—น๐—ฎ๐˜€๐˜ ๐—บ๐—ผ๐—ป๐˜๐—ต. Here is why they are different to LLMs even though both can achieve the same result ๐Ÿ‘‡

In decision models, you pass state, text or ose answers you declare in code. You get back a probability over those answers. Thatโ€™s it, and it is also the selling point, nothing to parse and validate.

On the other hand, asking an LLM for a bounded answer means:

๐Ÿญ. Option list and rubric go in the prompt
๐Ÿฎ. The model generates tokens, one forward pass each
๐Ÿฏ. You parse the string, validate the schema, retry on invalidation
๐Ÿฐ. The answer set is enforced after the text already exists

A decision model on the other hand makes the answer space an input, bounded before inference runs. With one scoring pass, you get a probability for every option you declare. Basically, a typed value with confidence attached.

Pros:

โœ… You get a distribution, not a label. Per-option probability allows you to write the decision policy once: act above a threshold, cheap second check in the middle band, escalate the tail.
โœ… Latency that significantly reduces the total latency of the loop. Jev runs P50 at 0.21 s and P95 at 0.34 s, and OpenAI advertises Decisions API to be close to 150 ms against roughly 1.6 s for the same model answering normally.
โœ… No cost on the output side. Jev is $0.042 per million input tokens with free output. Generally, output is the expensive half of a judgment.

What to be aware of:

โŒ Calibrated is a vendor claim. Check it against your own labelled set calibrate thresholds in house.
โŒ Accuracy degrades as irrelevant state grows. As always, keep your context as lean as possible.
โŒ Option names are more important for Decision Heads than the rubrics explaining them. Make sure to name them accordingly. I.e. refund_full_no_return instead of option_a.

๐Ÿ‘‰ Count the model calls in your agent loop, e.g.:

โžก๏ธ Routing
โžก๏ธ Is the retrieved context sufficient
โžก๏ธ Is the draft grounded
โžก๏ธ Do we escalate

All of these have finite answer sets and run as full LLM calls with schema on top today. However, only one really needs to generate some text.

โ—๏ธ There is still a lot of use case for complex structure outputs, not every problem can be solved with simple classifiers.

Looking forward to seeing decision models proliferate in architectures our clients are building!

Which decisions in your system are a full LLM call that did not need to be? ๐Ÿ‘‡
3
3
14
1,243
Aurimas Griciลซnas retweeted
Integrating ๐—”๐—ด๐—ฒ๐—ป๐˜๐—ถ๐—ฐ ๐—ฅ๐—”๐—š Systems via ๐— ๐—–๐—ฃ ๐Ÿ‘‡

If you are building RAG systems and packing many data sources for retrieval, most likely there is some agency present at least at the data source selection for retrieval stage.

This is how MCP enriches the evolution of s in such case (๐˜ฑ๐˜ฐ๐˜ช๐˜ฏ๐˜ต 2.):

๐Ÿญ. Analysis of the user query: we pass the original user query to a LLM based Agent for analysis. This is where:

โžก๏ธ The original query can be rewritten, sometimes multiple times to create either a single or multiple queries to be passed down the pipeline.
โžก๏ธ The agent decides if additional data sources are required to answer the query.

๐Ÿฎ. If additional data is required, the Retrieval step is triggered. We could tap into variety of data types, few examples:

โžก๏ธ Real time user data.
โžก๏ธ Internal documents that a user might be interested in.
โžก๏ธ Data available on the web.
โžก๏ธ โ€ฆ

๐—ง๐—ต๐—ถ๐˜€ ๐—ถ๐˜€ ๐˜„๐—ต๐—ฒ๐—ฟ๐—ฒ ๐— ๐—–๐—ฃ ๐—ฐ๐—ผ๐—บ๐—ฒ๐˜€ ๐—ถ๐—ป:

โœ… Each data domain can manage their own MCP Servers. Exposing specific rules of how the data should be used.
โœ… Security and compliance can be ensured on the Servel level for each domain.
โœ… New data domains can be easily added to the MCP server pool in a standardised way with no Agent rewrite needed enabling decoupled evolution of the system in terms of ๐—ฃ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐—ฑ๐˜‚๐—ฟ๐—ฎ๐—น, ๐—˜๐—ฝ๐—ถ๐˜€๐—ผ๐—ฑ๐—ถ๐—ฐ ๐—ฎ๐—ป๐—ฑ ๐—ฆ๐—ฒ๐—บ๐—ฎ๐—ป๐˜๐—ถ๐—ฐ ๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†.
โœ… Platform builders can expose their data in a standardised way to external consumers. Enabling easy access to data on the web.
โœ… AI Engineers can continue to focus on the topology of the Agent.

Learn all of this Hands-On in my End-to-End AI Engineering Bootcamp: maven.com/swirl-ai/end-tโ€ฆ . Next Cohort kicking off October 19th!

๐ŸŽ Use code YEAREND15 for 15% off.

๐Ÿฏ. Retrieved data is consolidated and Reranked by a more powerful model compared to regular embedder. Data points are significantly narrowed down.
๐Ÿฐ. If there is no need for additional data, we try to compose the answer (or multiple answers or a set of actions) straight via an LLM.
๐Ÿฑ. The answer gets analyzed, summarized and evaluated for correctness and relevance:

โžก๏ธ If the Agent decides that the answer is good enough, it gets returned to the user.
โžก๏ธ If the Agent decides that the answer needs improvement, we try to rewrite the user query and repeat the generation loop.

Are you using MCP in your Agentic RAG systems? Let me know about your experience in the comment section ๐Ÿ‘‡
8
6
30
2,370
Integrating ๐—”๐—ด๐—ฒ๐—ป๐˜๐—ถ๐—ฐ ๐—ฅ๐—”๐—š Systems via ๐— ๐—–๐—ฃ ๐Ÿ‘‡

If you are building RAG systems and packing many data sources for retrieval, most likely there is some agency present at least at the data source selection for retrieval stage.

This is how MCP enriches the evolution of s in such case (๐˜ฑ๐˜ฐ๐˜ช๐˜ฏ๐˜ต 2.):

๐Ÿญ. Analysis of the user query: we pass the original user query to a LLM based Agent for analysis. This is where:

โžก๏ธ The original query can be rewritten, sometimes multiple times to create either a single or multiple queries to be passed down the pipeline.
โžก๏ธ The agent decides if additional data sources are required to answer the query.

๐Ÿฎ. If additional data is required, the Retrieval step is triggered. We could tap into variety of data types, few examples:

โžก๏ธ Real time user data.
โžก๏ธ Internal documents that a user might be interested in.
โžก๏ธ Data available on the web.
โžก๏ธ โ€ฆ

๐—ง๐—ต๐—ถ๐˜€ ๐—ถ๐˜€ ๐˜„๐—ต๐—ฒ๐—ฟ๐—ฒ ๐— ๐—–๐—ฃ ๐—ฐ๐—ผ๐—บ๐—ฒ๐˜€ ๐—ถ๐—ป:

โœ… Each data domain can manage their own MCP Servers. Exposing specific rules of how the data should be used.
โœ… Security and compliance can be ensured on the Servel level for each domain.
โœ… New data domains can be easily added to the MCP server pool in a standardised way with no Agent rewrite needed enabling decoupled evolution of the system in terms of ๐—ฃ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐—ฑ๐˜‚๐—ฟ๐—ฎ๐—น, ๐—˜๐—ฝ๐—ถ๐˜€๐—ผ๐—ฑ๐—ถ๐—ฐ ๐—ฎ๐—ป๐—ฑ ๐—ฆ๐—ฒ๐—บ๐—ฎ๐—ป๐˜๐—ถ๐—ฐ ๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†.
โœ… Platform builders can expose their data in a standardised way to external consumers. Enabling easy access to data on the web.
โœ… AI Engineers can continue to focus on the topology of the Agent.

Learn all of this Hands-On in my End-to-End AI Engineering Bootcamp: maven.com/swirl-ai/end-tโ€ฆ . Next Cohort kicking off October 19th!

๐ŸŽ Use code YEAREND15 for 15% off.

๐Ÿฏ. Retrieved data is consolidated and Reranked by a more powerful model compared to regular embedder. Data points are significantly narrowed down.
๐Ÿฐ. If there is no need for additional data, we try to compose the answer (or multiple answers or a set of actions) straight via an LLM.
๐Ÿฑ. The answer gets analyzed, summarized and evaluated for correctness and relevance:

โžก๏ธ If the Agent decides that the answer is good enough, it gets returned to the user.
โžก๏ธ If the Agent decides that the answer needs improvement, we try to rewrite the user query and repeat the generation loop.

Are you using MCP in your Agentic RAG systems? Let me know about your experience in the comment section ๐Ÿ‘‡
8
6
30
2,370
Aurimas Griciลซnas retweeted
๐— ๐—–๐—ฃ plus ๐—”๐Ÿฎ๐—”, here is how they complement each other ๐Ÿ‘‡

Protocol wars continue to rage, let's understand how Googles A2A (Agent2Agent) protocol is different from MCP and how they complement each other (read till the end).

๐˜”๐˜ฐ๐˜ท๐˜ช๐˜ฏ๐˜จ ๐˜ฑ๐˜ช๐˜ฆ๐˜ค๐˜ฆ๐˜ด ๐˜ช๐˜ฏ ๐˜”๐˜Š๐˜—:

๐Ÿญ. MCP LMs at the core that want to access data through MCP.

โ—๏ธ When combined with A2A, an Agent becomes MCP Host.

๐Ÿฎ. MCP Client - Clients that maintain 1:1 connections with servers.
๐Ÿฏ. MCP Server - Lightweight programs that each expose specific capabilities through the standardised Model Context Protocol.
๐Ÿฐ. Local Data Sources - Your computerโ€™s files, databases, and services that MCP servers can securely access.
๐Ÿฑ. Remote Data Sources - External systems available over the internet (e.g., through APIs) that MCP servers can connect to.

๐˜Œ๐˜ฏ๐˜ต๐˜ฆ๐˜ณ ๐˜ˆ2๐˜ˆ:

Where MCP falls short, A2A tries to help. In multi-Agent applications where state is not necessarily shared

๐Ÿฒ. Agents (MCP Hosts) would implement and communicate via A2A protocol, that enables:

โžก๏ธ Secure Collaboration.
โžก๏ธ Task and State Management.
โžก๏ธ User Experience Negotiation.
โžก๏ธ Capability discovery - similar to MCP tools.

Learn all of this Hands-On in my End-to-End AI Engineering Bootcamp: maven.com/swirl-ai/end-tโ€ฆ . Next Cohort kicking off October 19th!

๐ŸŽ Use code YEAREND20 for 20% off - valid for the next two weeks.

๐—›๐—ผ๐—ป๐—ฒ๐˜€๐˜ ๐˜๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€:

โ—๏ธ Open protocols for Agent communication are important but they are just a piece of the picture, there will be a need for standards that govern all of the existing protocols and other missing pieces. E.g.

โ“ How do we standardise tracing and Observability in multi-agent IOA systems?
โ“ How do we retain the identity of the running job of an AI Agent instance if the communication standard is not unified in different parts of the pipeline?
โ“ ...

โœ… More on this in my future posts, stay tuned!

Let me know your thoughts in the comments. ๐Ÿ‘‡
3
3
16
1,654
๐— ๐—–๐—ฃ plus ๐—”๐Ÿฎ๐—”, here is how they complement each other ๐Ÿ‘‡

Protocol wars continue to rage, let's understand how Googles A2A (Agent2Agent) protocol is different from MCP and how they complement each other (read till the end).

๐˜”๐˜ฐ๐˜ท๐˜ช๐˜ฏ๐˜จ ๐˜ฑ๐˜ช๐˜ฆ๐˜ค๐˜ฆ๐˜ด ๐˜ช๐˜ฏ ๐˜”๐˜Š๐˜—:

๐Ÿญ. MCP LMs at the core that want to access data through MCP.

โ—๏ธ When combined with A2A, an Agent becomes MCP Host.

๐Ÿฎ. MCP Client - Clients that maintain 1:1 connections with servers.
๐Ÿฏ. MCP Server - Lightweight programs that each expose specific capabilities through the standardised Model Context Protocol.
๐Ÿฐ. Local Data Sources - Your computerโ€™s files, databases, and services that MCP servers can securely access.
๐Ÿฑ. Remote Data Sources - External systems available over the internet (e.g., through APIs) that MCP servers can connect to.

๐˜Œ๐˜ฏ๐˜ต๐˜ฆ๐˜ณ ๐˜ˆ2๐˜ˆ:

Where MCP falls short, A2A tries to help. In multi-Agent applications where state is not necessarily shared

๐Ÿฒ. Agents (MCP Hosts) would implement and communicate via A2A protocol, that enables:

โžก๏ธ Secure Collaboration.
โžก๏ธ Task and State Management.
โžก๏ธ User Experience Negotiation.
โžก๏ธ Capability discovery - similar to MCP tools.

Learn all of this Hands-On in my End-to-End AI Engineering Bootcamp: maven.com/swirl-ai/end-tโ€ฆ . Next Cohort kicking off October 19th!

๐ŸŽ Use code YEAREND20 for 20% off - valid for the next two weeks.

๐—›๐—ผ๐—ป๐—ฒ๐˜€๐˜ ๐˜๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€:

โ—๏ธ Open protocols for Agent communication are important but they are just a piece of the picture, there will be a need for standards that govern all of the existing protocols and other missing pieces. E.g.

โ“ How do we standardise tracing and Observability in multi-agent IOA systems?
โ“ How do we retain the identity of the running job of an AI Agent instance if the communication standard is not unified in different parts of the pipeline?
โ“ ...

โœ… More on this in my future posts, stay tuned!

Let me know your thoughts in the comments. ๐Ÿ‘‡
3
3
16
1,654
Aurimas Griciลซnas retweeted
๐—”๐—œ ๐—ข๐—ฏ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜† is a must have in your tool belt as an AI Engineer. ๐—ง๐—ฟ๐—ฎ๐—ฐ๐—ถ๐—ป๐—ด sits at the core of it, why is it important?

Tracing and instrumentation of software have been around for decades now. With AI systems resembling regular software even more, we are here as well (with a few key differences).

Letโ€™s look into the process of tracing from a perspective of a naive RAG system.

๐˜๐˜ฆ๐˜ธ ๐˜ฅ๐˜ฆ๐˜ง๐˜ช๐˜ฏ๐˜ช๐˜ต๐˜ช๐˜ฐ๐˜ฏ๐˜ด:

๐˜ผ) An Orchestrator in the GenAI system application is the central piece of software that orchestrates the end-to-end process. Think of apps using LangChain, LlamaIndex or Haystack.
๐˜ฝ) Trace is the end-to-end application flow from the entry point till the answer is produced, it is composed of smaller pieces called spans.
๐˜พ) Span is a smaller piece of the application flow that represents an atomic action like a function call or a database query. They can be sequential, or run in parallel.

โ„น๏ธ As part of span we capture general metadata like start and end time, inputs and outputs of the span. On top of this metadata we track information specific to the GenAI system elements.

What might a trace look like for a naive RAG system?

๐Ÿญ. A query that has been submitted to the chat application.
๐Ÿฎ. The query is embedded into a vector.

โœ… Additional metadata like input token count is persisted with the span so that we can estimate the cost of the procedure.

๐Ÿฏ. ANN lookup performed against the Vector DB to retrieve the most relevant context.

โœ… Additional metadata about the query is persisted as part of the span together with the retrieved pieces of context and their relevance.

๐Ÿฐ. A prompt is constructed from the system prompt and retrieved context.
๐Ÿฑ. The prompt is passed to the LLM to construct the answer.

โœ… Additional metadata about input and output token count is captured together with the span so that we can estimate the cost of the procedure.

๐˜ž๐˜ฉ๐˜บ ๐˜ช๐˜ด ๐˜ต๐˜ณ๐˜ข๐˜ค๐˜ช๐˜ฏ๐˜จ ๐˜ฐ๐˜ง ๐˜Ž๐˜ฆ๐˜ฏ๐˜ˆ๐˜ ๐˜ด๐˜บ๐˜ด๐˜ต๐˜ฆ๐˜ฎ๐˜ด ๐˜ช๐˜ฎ๐˜ฑ๐˜ฐ๐˜ณ๐˜ต๐˜ข๐˜ฏ๐˜ต?

- These applications are usually complex chains, errors can happen in different steps of your application. E.g. Embedding of query is taking longer than expected or you have reached API limits of LLM provider.
- Cost for calling LLM APIs will be variable depending on the length of inputs and produced outputs. You would usually trace this information and analyze it to help forecast expenses.
- GenAI systems are non-deterministic and will deteriorate over time. They need to be evaluated on span level rather than input/output of the entire system so that you can tune each piece separately.
- โ€ฆ

Are you tracing your Agents? Let me know in the comments ๐Ÿ‘‡
15
45
236
12,171
๐—”๐—œ ๐—ข๐—ฏ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ฎ๐—ฏ๐—ถ๐—น๐—ถ๐˜๐˜† is a must have in your tool belt as an AI Engineer. ๐—ง๐—ฟ๐—ฎ๐—ฐ๐—ถ๐—ป๐—ด sits at the core of it, why is it important?

Tracing and instrumentation of software have been around for decades now. With AI systems resembling regular software even more, we are here as well (with a few key differences).

Letโ€™s look into the process of tracing from a perspective of a naive RAG system.

๐˜๐˜ฆ๐˜ธ ๐˜ฅ๐˜ฆ๐˜ง๐˜ช๐˜ฏ๐˜ช๐˜ต๐˜ช๐˜ฐ๐˜ฏ๐˜ด:

๐˜ผ) An Orchestrator in the GenAI system application is the central piece of software that orchestrates the end-to-end process. Think of apps using LangChain, LlamaIndex or Haystack.
๐˜ฝ) Trace is the end-to-end application flow from the entry point till the answer is produced, it is composed of smaller pieces called spans.
๐˜พ) Span is a smaller piece of the application flow that represents an atomic action like a function call or a database query. They can be sequential, or run in parallel.

โ„น๏ธ As part of span we capture general metadata like start and end time, inputs and outputs of the span. On top of this metadata we track information specific to the GenAI system elements.

What might a trace look like for a naive RAG system?

๐Ÿญ. A query that has been submitted to the chat application.
๐Ÿฎ. The query is embedded into a vector.

โœ… Additional metadata like input token count is persisted with the span so that we can estimate the cost of the procedure.

๐Ÿฏ. ANN lookup performed against the Vector DB to retrieve the most relevant context.

โœ… Additional metadata about the query is persisted as part of the span together with the retrieved pieces of context and their relevance.

๐Ÿฐ. A prompt is constructed from the system prompt and retrieved context.
๐Ÿฑ. The prompt is passed to the LLM to construct the answer.

โœ… Additional metadata about input and output token count is captured together with the span so that we can estimate the cost of the procedure.

๐˜ž๐˜ฉ๐˜บ ๐˜ช๐˜ด ๐˜ต๐˜ณ๐˜ข๐˜ค๐˜ช๐˜ฏ๐˜จ ๐˜ฐ๐˜ง ๐˜Ž๐˜ฆ๐˜ฏ๐˜ˆ๐˜ ๐˜ด๐˜บ๐˜ด๐˜ต๐˜ฆ๐˜ฎ๐˜ด ๐˜ช๐˜ฎ๐˜ฑ๐˜ฐ๐˜ณ๐˜ต๐˜ข๐˜ฏ๐˜ต?

- These applications are usually complex chains, errors can happen in different steps of your application. E.g. Embedding of query is taking longer than expected or you have reached API limits of LLM provider.
- Cost for calling LLM APIs will be variable depending on the length of inputs and produced outputs. You would usually trace this information and analyze it to help forecast expenses.
- GenAI systems are non-deterministic and will deteriorate over time. They need to be evaluated on span level rather than input/output of the entire system so that you can tune each piece separately.
- โ€ฆ

Are you tracing your Agents? Let me know in the comments ๐Ÿ‘‡
15
45
236
12,171
๐— ๐—–๐—ฃ plus ๐—”๐Ÿฎ๐—”, here is how they complement each other ๐Ÿ‘‡

Protocol wars continue to rage, let's understand how Googles A2A (Agent2Agent) protocol is different from MCP and how they complement each other (read till the end).

๐˜”๐˜ฐ๐˜ท๐˜ช๐˜ฏ๐˜จ ๐˜ฑ๐˜ช๐˜ฆ๐˜ค๐˜ฆ๐˜ด ๐˜ช๐˜ฏ ๐˜”๐˜Š๐˜—:

๐Ÿญ. MCP LMs at the core that want to access data through MCP.

โ—๏ธ When combined with A2A, an Agent becomes MCP Host.

๐Ÿฎ. MCP Client - Clients that maintain 1:1 connections with servers.
๐Ÿฏ. MCP Server - Lightweight programs that each expose specific capabilities through the standardised Model Context Protocol.
๐Ÿฐ. Local Data Sources - Your computerโ€™s files, databases, and services that MCP servers can securely access.
๐Ÿฑ. Remote Data Sources - External systems available over the internet (e.g., through APIs) that MCP servers can connect to.

๐˜Œ๐˜ฏ๐˜ต๐˜ฆ๐˜ณ ๐˜ˆ2๐˜ˆ:

Where MCP falls short, A2A tries to help. In multi-Agent applications where state is not necessarily shared

๐Ÿฒ. Agents (MCP Hosts) would implement and communicate via A2A protocol, that enables:

โžก๏ธ Secure Collaboration.
โžก๏ธ Task and State Management.
โžก๏ธ User Experience Negotiation.
โžก๏ธ Capability discovery - similar to MCP tools.

๐—›๐—ผ๐—ป๐—ฒ๐˜€๐˜ ๐˜๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€:

โ—๏ธ Open protocols for Agent communication are important but they are just a piece of the picture, there will be a need for standards that govern all of the existing protocols and other missing pieces. E.g.

โ“ How do we standardise tracing and Observability in multi-agent IOA systems?
โ“ How do we retain the identity of the running job of an AI Agent instance if the communication standard is not unified in different parts of the pipeline?
โ“ ...

โœ… More on this in my future posts, stay tuned!

Let me know your thoughts in the comments. ๐Ÿ‘‡
6
10
58
2,834
Aurimas Griciลซnas retweeted
๐—”๐—œ ๐—ณ๐—ฒ๐—ฎ๐˜๐˜‚๐—ฟ๐—ฒ๐˜€ ๐—ถ๐—ป ๐—ฎ ๐—ฆ๐—ฎ๐—ฎ๐—ฆ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜ ๐—ฎ๐—ฟ๐—ฒ ๐—ฎ๐—ป ๐—ถ๐—ป๐—ณ๐—ฟ๐—ฎ๐˜€๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐—ฏ๐—น๐—ฒ๐—บ ๐—ฎ๐˜€ ๐—บ๐˜‚๐—ฐ๐—ต ๐—ฎ๐˜€ ๐—ฎ ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ฝ๐—ฟ๐—ผ๐—ฏ๐—น๐—ฒ๐—บ.

Every software company is wiring AI into its product right now and the work concentrates in the gap between a prototype and a product that serves thousands. This is what I mean:

โžก๏ธ Inference traffic is bursty and grows with every tenant you onboard
โžก๏ธ Tenant data has to stay isolated through every retrieval step and model call
โžก๏ธ Regulated buyers ask about SOC 2, HIPAA and ISO 27001 before they ask about features
โžก๏ธ Once the product works, you still need a path into enterprise procurement

This is where the ๐—”๐—ช๐—ฆ ๐—œ๐—ฆ๐—ฉ resources made sense for me, one platform covering the full scope from building to selling:

โœ… Compute that matches your workload shape: Lambda for spiky event-driven paths, ECS or EKS for long-running multi-tenant services
๐Ÿ‘† The mistake is picking one shape for the whole product. Inference paths and ingestion jobs have almost nothing in common except that they both run your code.

โœ… Amazon Bedrock with over 100 foundation models, so AI features ship without a model-serving layer of your own

โœ… A data layer designed for per-tenant isolation, from Aurora and DynamoDB to OpenSearch for retrieval
โœ… Security primitives (IAM, VPC isolation, encryption at rest and in transit) that map directly onto the compliance controls regulated industries require
๐Ÿ‘† These are the two teams defer but pay for later. Adding isolation after launch means reopening every query path and every retrieval call you've already shipped.

โœ… AWS Marketplace and ISV Accelerate co-sell, which turn enterprise procurement into a channel instead of a grind

๐Ÿ‘‰ See how software companies are building on AWS: fandf.co/3RSKMRf

Follow @awscloud for more on what ISVs are shipping on the platform.

๐‘‡โ„Ž๐‘–๐‘  ๐‘๐‘œ๐‘ ๐‘ก ๐‘–๐‘  ๐‘ ๐‘๐‘œ๐‘›๐‘ ๐‘œ๐‘Ÿ๐‘’๐‘‘ ๐‘๐‘ฆ ๐ด๐‘Š๐‘†.

If you are building AI into a SaaS product, which part has been harder in practice: the model side, or the multi-tenant infrastructure around it? ๐Ÿ‘‡
4
12
46
3,354
๐—”๐—œ ๐—ณ๐—ฒ๐—ฎ๐˜๐˜‚๐—ฟ๐—ฒ๐˜€ ๐—ถ๐—ป ๐—ฎ ๐—ฆ๐—ฎ๐—ฎ๐—ฆ ๐—ฝ๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜ ๐—ฎ๐—ฟ๐—ฒ ๐—ฎ๐—ป ๐—ถ๐—ป๐—ณ๐—ฟ๐—ฎ๐˜€๐˜๐—ฟ๐˜‚๐—ฐ๐˜๐˜‚๐—ฟ๐—ฒ ๐—ฝ๐—ฟ๐—ผ๐—ฏ๐—น๐—ฒ๐—บ ๐—ฎ๐˜€ ๐—บ๐˜‚๐—ฐ๐—ต ๐—ฎ๐˜€ ๐—ฎ ๐—บ๐—ผ๐—ฑ๐—ฒ๐—น ๐—ฝ๐—ฟ๐—ผ๐—ฏ๐—น๐—ฒ๐—บ.

Every software company is wiring AI into its product right now and the work concentrates in the gap between a prototype and a product that serves thousands. This is what I mean:

โžก๏ธ Inference traffic is bursty and grows with every tenant you onboard
โžก๏ธ Tenant data has to stay isolated through every retrieval step and model call
โžก๏ธ Regulated buyers ask about SOC 2, HIPAA and ISO 27001 before they ask about features
โžก๏ธ Once the product works, you still need a path into enterprise procurement

This is where the ๐—”๐—ช๐—ฆ ๐—œ๐—ฆ๐—ฉ resources made sense for me, one platform covering the full scope from building to selling:

โœ… Compute that matches your workload shape: Lambda for spiky event-driven paths, ECS or EKS for long-running multi-tenant services
๐Ÿ‘† The mistake is picking one shape for the whole product. Inference paths and ingestion jobs have almost nothing in common except that they both run your code.

โœ… Amazon Bedrock with over 100 foundation models, so AI features ship without a model-serving layer of your own

โœ… A data layer designed for per-tenant isolation, from Aurora and DynamoDB to OpenSearch for retrieval
โœ… Security primitives (IAM, VPC isolation, encryption at rest and in transit) that map directly onto the compliance controls regulated industries require
๐Ÿ‘† These are the two teams defer but pay for later. Adding isolation after launch means reopening every query path and every retrieval call you've already shipped.

โœ… AWS Marketplace and ISV Accelerate co-sell, which turn enterprise procurement into a channel instead of a grind

๐Ÿ‘‰ See how software companies are building on AWS: fandf.co/3RSKMRf

Follow @awscloud for more on what ISVs are shipping on the platform.

๐‘‡โ„Ž๐‘–๐‘  ๐‘๐‘œ๐‘ ๐‘ก ๐‘–๐‘  ๐‘ ๐‘๐‘œ๐‘›๐‘ ๐‘œ๐‘Ÿ๐‘’๐‘‘ ๐‘๐‘ฆ ๐ด๐‘Š๐‘†.

If you are building AI into a SaaS product, which part has been harder in practice: the model side, or the multi-tenant infrastructure around it? ๐Ÿ‘‡
4
12
46
3,354
Aurimas Griciลซnas retweeted
Integrating ๐—”๐—ด๐—ฒ๐—ป๐˜๐—ถ๐—ฐ ๐—ฅ๐—”๐—š Systems via ๐— ๐—–๐—ฃ ๐Ÿ‘‡

If you are building RAG systems and packing many data sources for retrieval, most likely there is some agency present at least at the data source selection for retrieval stage.

This is how MCP enriches the evolution of s in such case (๐˜ฑ๐˜ฐ๐˜ช๐˜ฏ๐˜ต 2.):

๐Ÿญ. Analysis of the user query: we pass the original user query to a LLM based Agent for analysis. This is where:

โžก๏ธ The original query can be rewritten, sometimes multiple times to create either a single or multiple queries to be passed down the pipeline.
โžก๏ธ The agent decides if additional data sources are required to answer the query.

๐Ÿฎ. If additional data is required, the Retrieval step is triggered. We could tap into variety of data types, few examples:

โžก๏ธ Real time user data.
โžก๏ธ Internal documents that a user might be interested in.
โžก๏ธ Data available on the web.
โžก๏ธ โ€ฆ

๐—ง๐—ต๐—ถ๐˜€ ๐—ถ๐˜€ ๐˜„๐—ต๐—ฒ๐—ฟ๐—ฒ ๐— ๐—–๐—ฃ ๐—ฐ๐—ผ๐—บ๐—ฒ๐˜€ ๐—ถ๐—ป:

โœ… Each data domain can manage their own MCP Servers. Exposing specific rules of how the data should be used.
โœ… Security and compliance can be ensured on the Servel level for each domain.
โœ… New data domains can be easily added to the MCP server pool in a standardised way with no Agent rewrite needed enabling decoupled evolution of the system in terms of ๐—ฃ๐—ฟ๐—ผ๐—ฐ๐—ฒ๐—ฑ๐˜‚๐—ฟ๐—ฎ๐—น, ๐—˜๐—ฝ๐—ถ๐˜€๐—ผ๐—ฑ๐—ถ๐—ฐ ๐—ฎ๐—ป๐—ฑ ๐—ฆ๐—ฒ๐—บ๐—ฎ๐—ป๐˜๐—ถ๐—ฐ ๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†.
โœ… Platform builders can expose their data in a standardised way to external consumers. Enabling easy access to data on the web.
โœ… AI Engineers can continue to focus on the topology of the Agent.

๐Ÿฏ. Retrieved data is consolidated and Reranked by a more powerful model compared to regular embedder. Data points are significantly narrowed down.
๐Ÿฐ. If there is no need for additional data, we try to compose the answer (or multiple answers or a set of actions) straight via an LLM.
๐Ÿฑ. The answer gets analyzed, summarized and evaluated for correctness and relevance:

โžก๏ธ If the Agent decides that the answer is good enough, it gets returned to the user.
โžก๏ธ If the Agent decides that the answer needs improvement, we try to rewrite the user query and repeat the generation loop.

Are you using MCP in your Agentic RAG systems? Let me know about your experience in the comment section ๐Ÿ‘‡
12
81
387
19,326