ExamplesAI Agent Decision

AI Agent Decision with Memory

AI is additive. Same timeline primitives as access requests and payment disputes — memory as state, decisions as events, tool calls as inspectable side effects.

Full walkthrough: Support Copilot.


Old fragile flow

agent receives message
  → ad-hoc vector lookup
  → OpenAI call in service code
  → write ticket fields
  → maybe tool-call refund
  → no durable record of which memory or prompt version was used

Causet version

CREATE_TICKET / TRIAGE_TICKET intent
  → core: persist ticket + TICKET_CREATED
  → side_effects: op: decision (memories + prompt)
  → emit TICKET_AI_TRIAGED
  → optional HUMAN_REVIEW_REQUESTED
  → tool calls / submits as side effects on the timeline

Sample intent + decision

actions:
  TRIAGE_TICKET:
    state: support_ticket
    entity_id_expr: intent.ticket_id
    input:
      ticket_id:   { type: string, required: true }
      customer_id: { type: string, required: true }
    side_effects:
      rules:
        - name: run_triage
          then:
            - op: decision
              ref: ticket_triage
              input:
                ticket_id: intent.ticket_id
                customer_id: intent.customer_id
 
decisions:
  ticket_triage:
    provider: reasoning
    prompt: triage_v1
    emits: TICKET_AI_TRIAGED
    memories:
      - customer_history
    output:
      priority:   { type: string, required: true }
      confidence: { type: number, required: true }

Sample events

TICKET_CREATED
TICKET_AI_TRIAGED
HUMAN_REVIEW_REQUESTED
HUMAN_APPROVAL_GRANTED

Sample query

queries:
  ticket_triage_status:
    from: ticket_triage_status
    where:
      ticket_id: { eq: input.ticket_id }

Timeline output

TRIAGE_TICKET (tkt_42)
  ✓ TICKET_CREATED
  ✓ decision ticket_triage (memory: customer_history)
  ✓ TICKET_AI_TRIAGED
  ✓ HUMAN_REVIEW_REQUESTED   (confidence < threshold)

What you can inspect

  • Which memories were retrieved
  • Prompt / provider version
  • Structured decision output and confidence
  • Whether a human approval overrode the model

What you can replay or repair

  • Fork before a bad decision and re-run with corrected prompt
  • Emit a compensating business event for the app DB
  • Audit tool calls without re-firing them on projection rebuild

Related: AI in Causet · Webhooks bridge.