Chapter 21 · Production Agents LangChain Track CLI Project

From JIRA key to a grounded triage decision in one command.

A production-ready LangChain agent: give it one or more JIRA keys, it pulls each ticket over the REST API, retrieves the three most similar past bugs and test cases from a local Chroma knowledge base, and returns a structured Triage with severity, priority, component, owning team, duplicate flag and reasoning.

01 What students build

The first of Chapter 21's production agents (src/prod/bug_traige_agent_prod_ready.py). A fetch_jira_ticket tool hits JIRA REST v3 and flattens the Atlassian Document Format description into a plain bug report. A RAG knowledge base (built once with python -m rag.ingest) supplies precedent: similar past bugs, test cases, related VWO tickets and PDFs. Groq's gpt-oss-120b then triages with json_schema structured output, so the Pydantic Triage comes back with real booleans, never "False" as a string.

Live JIRA Tool

A LangChain @tool that fetches summary, type, priority, status, components and reporter for any key, with a recursive ADF-to-text flattener for v3 descriptions.

RAG-Grounded Precedent

Top-3 similar items from Chroma + Ollama nomic-embed-text. If past bugs map a component to a team and severity, the agent follows that mapping.

Structured Triage

A Pydantic schema: title, severity, priority, component, suggested_team, likely_duplicate, reasoning. Constrained generation, not parsed prose.

02 Architecture

JIRA key(s)VWO-24, VWO-217…
──▶
fetch_jira_ticketREST v3 + ADF flatten
──▶
RAG retrieveChroma · top-3
──▶
ChatGroqgpt-oss-120b · json_schema
──▶
Triagepydantic · 7 fields
knowledge base: past bugs · test_cases.csv · related tickets · pdfs · degrades gracefully when rag is offline

03 Live demo (simulated with sample data)

This is a UI walkthrough with pre-baked sample data so you can feel the triage flow without JIRA credentials. In the course you run the real thing: a .env with Groq + JIRA keys, Ollama embeddings and a local Chroma DB built by python -m rag.ingest.

python src/prod/bug_traige_agent_prod_ready.py demo · sample data

04 Inputs & outputs

What goes in

  • One or more JIRA keys, or a raw pasted bug report
  • .env: GROQ_API_KEY, LLM_MODEL, JIRA_URL, JIRA_EMAIL, JIRA_API_TOKEN
  • A Chroma knowledge base built by python -m rag.ingest
  • Knowledge sources: BUG-0xx reports, test_cases.csv, tickets, PDFs

What comes out

  • A structured Triage per ticket: severity, priority, component, team
  • likely_duplicate flag with the matching past bug
  • Top-3 RAG precedents with similarity scores
  • 2-3 line reasoning grounded in prior knowledge, printed one by one

05 How it's built

Define the Triage Pydantic schema: title, severity, priority, component, suggested_team, likely_duplicate, reasoning.
Build the fetch_jira_ticket @tool: JIRA REST v3 with basic auth, plus a recursive flattener for Atlassian Document Format descriptions.
Ingest the knowledge base once with python -m rag.ingest: past bug reports, test_cases.csv, related tickets and PDFs into Chroma via Ollama nomic-embed-text.
Retrieve top-3 precedents per report with get_rag_context, degrading gracefully to empty context if Ollama is down.
Chain prompt | llm.with_structured_output(Triage, method="json_schema") on ChatGroq, so booleans come back as real booleans.
Loop over the keys, fetch, ground, triage and print each Triage, ready to batch a whole sprint's intake.

06 Tech stack

LangChainChatGroq · gpt-oss-120bPydantic structured outputJIRA REST API v3ChromaDBOllama nomic-embed-textPythonpython-dotenv