https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons
https://www.youtube.com/watch?v=ldqOnljDINc
Three Types of Roles
Reference : https://medium.com/@chiwai.kiriba/the-anatomy-of-a-prompt-system-user-and-assistant-roles-d514cbc621ce
- User : what the user says
- System : the persona you are giving to AI
- Assistant : the model’s output. It is what the AI generates in response to the System and User messages
- Each message or prompt has to be associated with a role
- Role defines what an entity does
- User Prompt ( Ask ) : How is weather
- Assistant Prompt (Response) : it is sunny
What is Agent ?
AI Agents are programs where LLM outputs control the workflow
In practice defines an AI solution that involved any of the following
Multiple LLM calls
LLMs with ability to use tools
An environment where LLMs interact
A planner to coordinate activities
Autonomy
Chat Vs Agent
different agentic levels
Anthropic distinguishes two types of Agentic Systems
- Workflows are systems where LLMs and tools are orchestrated through predefined code paths
- Agents are systems where LLMs dynamically their own process and tool usage maintaining control over how they accomplish their task
✅ When to use agents / ⛔ When to avoid them
Agents are useful when you need an LLM to determine the workflow of an app. But they’re often overkill. The question is: do I really need flexibility in the workflow to efficiently solve the task at hand? If the pre-determined workflow falls short too often, that means you need more flexibility. Let’s take an example: say you’re making an app that handles customer requests on a surfing trip website.
You could know in advance that the requests will belong to either of 2 buckets (based on user choice), and you have a predefined workflow for each of these 2 cases.
Want some knowledge on the trips? ⇒ give them access to a search bar to search your knowledge base
Wants to talk to sales? ⇒ let them type in a contact form.
If that deterministic workflow fits all queries, by all means just code everything! This will give you a 100% reliable system with no risk of error introduced by letting unpredictable LLMs meddle in your workflow. For the sake of simplicity and robustness, it’s advised to regularize towards not using any agentic behaviour.
But what if the workflow can’t be determined that well in advance?
For instance, a user wants to ask: "I can come on Monday, but I forgot my passport so risk being delayed to Wednesday, is it possible to take me and my stuff to surf on Tuesday morning, with cancellation insurance?" This question hinges on many factors, and probably none of the predetermined criteria above will suffice for this request.
If the pre-determined workflow falls short too often, that means you need more flexibility.
That is where an agentic setup helps
When calling the Claude Messages API, the stop_reason field in a successful (http 200) response explains why the model finished generating.
You should evaluate this field to determine your next step: accepting the response, continuing the conversation, retrying, or falling back to an alternative model. Note that this field is completely omitted if the request encounters an API error or processing failure.
end_turn
- ok