Week 4 Final Goal

Claim state
→ LangChain agent chooses next tool/action
→ ClaimFlow guardrails validate the action
→ safe tool executes
→ unsafe action is blocked
→ action is logged
→ final workflow state is correct
→ eval proves routing is safe

The week’s demo should show:

Missing FIR / police report
→ agent chooses follow-up request
→ system drafts follow-up
→ approval is blocked
→ review task becomes NEEDS_MORE_INFO
→ new evidence is uploaded
→ review is reopened
→ timeline shows all agent actions

What You Are Learning This Week

Week 4 teaches these AI workflow topics:

LangChain tool calling
Tool schemas with Zod
Agent-as-router pattern
Tool orchestration
ReAct-style workflow loop
Guarded agent execution
Human-in-the-loop routing
Agent action logging
Agent evals
Multi-document claim packet reasoning
Evidence follow-up loop

The most important mental model:

LangChain agent = decides what tool it wants to call

ClaimFlow guardrails = decide whether that tool call is allowed

ClaimFlow tools = execute real product actions

ClaimFlow DB = source of truth

Do not let LangChain own your workflow state machine.


Final Folder Structure

Add:

packages/agent/
  package.json
  index.ts

  planner/
    create-claimflow-agent.ts
    build-agent-context.ts
    agent-system-prompt.ts
    parse-agent-tool-call.ts

  tools/
    retrieve-policy-clauses.tool.ts
    create-review-task.tool.ts
    draft-followup-request.tool.ts
    mark-needs-more-evidence.tool.ts
    escalate-to-human.tool.ts
    draft-approval-note.tool.ts
    draft-denial-reason.tool.ts
    ask-clarification.tool.ts

  guardrails/
    evaluate-agent-action.ts
    guardrail-rules.ts
    action-permission-matrix.ts

  runner/
    run-agent-step.ts
    execute-agent-tool.ts

  scripts/
    smoke-test-agent-step.ts

Add shared schema:

packages/shared/schemas/agent_actions.ts

Add eval:

packages/evals/evaluate-week4-agent-actions.ts

Add dataset: