Shipping your agent
Wrap the agent in a FastAPI endpoint that streams tokens and tool events over SSE, add two levels of timeout, keep state in a shared database, package it in a container, turn on tracing, and report what every conversation costs.
@theDevsDaily🐦
Wrap the agent in a FastAPI endpoint that streams tokens and tool events over SSE, add two levels of timeout, keep state in a shared database, package it in a container, turn on tracing, and report what every conversation costs.
A prompt is a request, not a rule. Take identity from the session, authorise inside every tool, treat documents and tool results as untrusted data, mask personal data before it reaches the model provider, cap model and tool calls, and log every action.
Agents word things differently on every run, so test facts, not sentences. A fixed set of cases is checked in three layers (answer text, tool trajectory and a rubric-based judge model), and a pytest gate in CI fails the build when quality drops below a threshold.
Build a supervisor with payroll and policy specialists as tools, then compare it with a single agent on the same 30 questions for accuracy, latency and tokens. Split only when the numbers say so, and save Deep Agents for long, multi-step jobs that need a plan and a scratchpad.
interrupt() pauses a graph and saves its state, and Command(resume=…) continues it later, even from a new process after a restart. For free-form agents, HumanInTheLoopMiddleware makes chosen tools wait for approve, edit or reject. Writes wait; reads flow.
Booking leave is a process, not a chat. In a LangGraph graph, code owns the order of steps and the rules (valid dates, enough balance, submit once), the model only turns a sentence into fields, and an agent can still be one node in the graph.
Index the employee handbook once (split by headings, embed, store), then expose search as a tool the agent calls only when a question is about policy. Results carry their section names for citations, weak matches are dropped, and the prompt makes the agent say "I don’t know" when nothing fits.
A checkpointer keeps each conversation thread, a store keeps lasting facts about the person, runtime context tells tools who is asking, and SummarizationMiddleware keeps long threads affordable. You also decide in code what must never be remembered.
Most agent failures are tool failures. Write descriptions that say when to use a tool, validate arguments with Pydantic, return errors with a hint the model can act on, make writes safe to retry, and load tools another team owns from an MCP server.
LangChain’s create_agent runs the Part 1 loop for you. @tool turns typed, documented functions into tools, and response_format returns a validated Pydantic object instead of free text, so your app gets fields it can trust.