Loquent · AI Operations

AI Operations Inventory

Every place the codebase calls an AI model — what it does, what goes in and out, which call shape it uses, and the source file. Use it as a map for adding new call sites and as a pre-flight checklist for migrating off aisdk onto rig.

Total call sites
32
OpenAI REST
3
Transcription
single-shot / text
4
single-shot / json
18
agentic
4
streaming + agentic
1
Assistant
Current stack
What each concern uses today, and what the rig migration has to replace.
Concern Today Migration target
LLM SDK aisdk::core::LanguageModelRequest via Openrouter::<DynamicModel> Replace builder + generate_text()/stream_text() with rig agent calls
Model resolution crate::mods::ai::resolve_model(AiArea::*) → model id string Keep AiArea enum, swap resolver target
Structured output schemars::JsonSchema on a private struct + generate_text() returning typed JSON Map to rig structured-output / extractor APIs
Tools .with_tool(t) + step_count_is(N) stop condition Map to rig tool registration + agent loop
Streaming .stream_text() + LanguageModelStreamChunkType Map to rig streaming agent
Usage logging /add-ai-logging skill — required at every call site Preserve identical fields/args
Transcription OpenAI REST via reqwest::multipart (not aisdk) Out of scope — leave as-is

Mode legend

Each call site is tagged with one of these. Look for the colored dot.

OpenAI REST
Raw multipart upload via reqwest. Used only for transcription.
single-shot / text
One prompt, plain-text answer. No tools, no schema.
single-shot / json
One prompt, typed JSON answer via schemars::JsonSchema.
agentic
Tool-using loop with a step_count_is(N) stop.
streaming + agentic
Chunked output with tool calls. Only the in-app assistant.
wrapper
Orchestration around another AI op — not a model call itself.

User-facing pipelines

Where each call site sits in the larger flow. Each box is one AI op or a small group of related ops.

Post-call pipeline

REST
Transcribe
audio → transcript
json
Identify speakers
label → role
textjson
Analyze · Summarize · Auto-tag
analyzers + summary + tags
json
Enrich · Tasks · Plans
contact fields, tasks, plans

Inbound SMS pipeline

agentic
Text agent reply
single reply or 3 suggestions
json
Memory + tasks + enrichment
batched per contact
json
Create plans from SMS
match templates → instantiate

Plan execution loop

json
Instantiate plan
title + description from template
agentic
Execute plan (loop)
custom plan tools · step_count_is(25) · fallback model

In-app assistant

streaming + agentic
Run assistant
full tool suite · MAX_TOOL_STEPS · streamed chunks
text
Generate title
first messages → title

Transcription

Raw OpenAI REST. Outside the aisdk → rig migration scope.

Transcribe audio
OpenAI REST

Default OpenAI transcription wrapper.

I/O: audio bytes TranscriptionResponse
src/mods/openai/utils/transcribe_audio_util.rs
Transcribe audio (options)
OpenAI REST

Custom transcription request params.

I/O: bytes + TranscriptionRequest TranscriptionResponse
src/mods/openai/utils/transcribe_audio_with_options_util.rs
Transcribe audio (diarized)
OpenAI REST

Speaker-labeled via gpt-4o-transcribe-diarize.

I/O: bytes DiarizedTranscriptionResponse
src/mods/openai/utils/transcribe_audio_diarized_util.rs
Identify speakers
single-shot / json

Map diarized labels to AI vs. caller.

I/O: diarized transcript HashMap<label, role>
AiArea: IdentifySpeakers
src/mods/openai/utils/identify_speakers_util.rs
Process Twilio recording
wrapper

Orchestrate download + transcription.

I/O: TwilioRecordingRequest transcription
src/mods/twilio/utils/process_twilio_recording_util.rs

Call Analysis

Post-call pipeline. Runs after a recording is transcribed.

Analyze call text
single-shot / text

Run an analyzer's custom prompt on a transcription.

I/O: prompt + transcription free text
AiArea: AnalyzeCall
src/mods/analyzer/utils/analyze_call_text_util.rs
Auto-tag contact
single-shot / json

Pick org tags relevant to a call.

I/O: summary + tag list tag_ids[]
AiArea: AutoTagContact
src/mods/contact/services/auto_tag_contact_from_call_service.rs
Enrich contact (call)
single-shot / json

Fill stub contact fields from transcription.

I/O: transcription {first_name, last_name, company, …}
AiArea: EnrichContact
src/mods/contact/services/enrich_contact_service.rs
Summarize call
single-shot / json

Markdown summary for an interaction note.

I/O: transcription sectioned markdown
AiArea: SummarizeCall
src/mods/contact/services/notes/summarize_call_for_note_service.rs
Extract tasks (call)
single-shot / json

Extract actionable tasks from a call.

I/O: transcription tasks[{title,…}]
AiArea: ExtractTasks
src/mods/task/services/create_tasks_from_call_service.rs
Create plans (call)
single-shot / json ×N

Match post_call-trigger templates and spawn plans.

I/O: call + templates relevance + instantiated plans
AiArea: AssessPlanTemplateStartCondition InstantiatePlan
src/mods/plan/services/create_plans_from_call_service.rs

Contact memory & enrichment

Message-pipeline counterparts to the call-pipeline enrichment ops.

Update contact memory
single-shot / json

Refresh memory note from new call/SMS context.

I/O: profile + transcript/messages updated memory note
AiArea: UpdateSystemNote UpdateContactMemoryFromMessages
src/mods/contact/services/notes/update_contact_memory_service.rs
Analyze contact messages
single-shot / json

Extract memory + tasks from unprocessed SMS batch.

I/O: message batch {memory_updates, tasks}
AiArea: ExtractTasksFromMessages
src/mods/contact/services/ai/analyze_contact_messages_service.rs
Enrich contact (messages)
single-shot / json

Fill contact fields from SMS history.

I/O: message history contact attributes
AiArea: EnrichContactFromMessages
src/mods/contact/services/ai/enrich_contact_from_messages_service.rs

Plans

Template matching, instantiation, and the agentic execution loop.

Create plans from SMS
single-shot / json ×N

Match new_sms-trigger templates and instantiate.

I/O: sms + templates instantiated plans
AiArea: AssessPlanTemplateStartCondition InstantiatePlan
src/mods/plan/services/create_plans_from_sms_service.rs
Create plan from template
single-shot / json

Generate contextual title/description for a contact.

I/O: contact ctx + template {title, description}
AiArea: InstantiatePlan
src/mods/plan/services/create_plan_from_template_service.rs
Execute plan
agentic

Agentic loop driving plan actions — custom plan tools, step_count_is(25), fallback model.

I/O: plan state tool calls + log entries
AiArea: ExecutePlan ExecutePlanFallback
src/mods/plan/services/execute_plan_service.rs

Text Agent

Inbound SMS handlers — direct reply or suggestions for review.

Generate single reply
agentic

One direct reply for an inbound message — query_knowledge, step_count_is(5).

I/O: conversation + agent config text reply
AiArea: TextAgentSingleReply
src/mods/text_agent/services/generate_text_agent_single_reply_service.rs
Generate suggestions
agentic

Three reply candidates for human review.

I/O: conversation + agent config TextAgentSuggestions{items[]}
AiArea: TextAgentSuggestions
src/mods/text_agent/services/generate_text_agent_suggestions_service.rs

Assistant

In-app agentic chat. The only streaming call site.

Run assistant
streaming + agentic

In-app agentic chat — full assistant tool suite, MAX_TOOL_STEPS.

I/O: messages + page ctx streamed chunks + tool calls
AiArea: Assistant
src/mods/assistant/services/assistant_service.rs
Generate conversation title
single-shot / text

Persist a short title for an assistant chat.

I/O: first messages title string
AiArea: AssistantTitle
src/mods/assistant/services/generate_title_service.rs

Knowledge

KB query — used as a tool inside the text-agent and assistant loops.

Query knowledge
single-shot / text

Extract concise answer from KB documents.

I/O: query + KB docs answer text
AiArea: KnowledgeQuery
src/mods/agent/services/handle_query_knowledge_tool_call_service.rs

Dashboard & Reports

Briefing cards and the daily org report.

Dashboard briefing
single-shot / json

Daily structured briefing card.

I/O: user data ctx JSON briefing
AiArea: DashboardBriefing
src/mods/dashboard/services/generate_dashboard_briefing_service.rs
Detailed briefing
agentic

Investigative briefing with tool calls — dashboard tools, step_count_is(10).

I/O: scope JSON briefing
AiArea: DashboardDetailedBriefing
src/mods/dashboard/services/generate_detailed_briefing_service.rs
Daily report
single-shot / text

End-of-day org report.

I/O: calls + messages window report text
AiArea: GenerateReport
src/mods/report/services/generate_daily_report_service.rs

AI Builder (authoring UX)

All consume Session and run via Dioxus #[post] server functions. All return structured JSON via JsonSchema.

Generate instructions
single-shot / json

Instructions from a description.

I/O: AiBuilderGenerateRequest AiBuilderResponse
AiArea: GenerateInstructions
src/shared/ai_builder/api/generate_api.rs
Edit instructions (preset)
single-shot / json

Apply preset action to instructions.

I/O: AiBuilderEditRequest AiBuilderResponse
AiArea: EditInstructions
src/shared/ai_builder/api/edit_api.rs
Edit instructions (custom)
single-shot / json

Free-text edit of instructions.

I/O: AiBuilderCustomEditRequest AiBuilderResponse
AiArea: CustomEditInstructions
src/shared/ai_builder/api/custom_edit_api.rs
Generate text agent
single-shot / json

All four text-agent fields.

I/O: TextAgentGenerateRequest TextAgentAiResponse
AiArea: GenerateInstructions
src/shared/ai_builder/api/text_agent_generate_api.rs
Edit text agent (preset)
single-shot / json

Preset action across four fields.

I/O: TextAgentEditRequest TextAgentAiResponse
AiArea: EditInstructions
src/shared/ai_builder/api/text_agent_edit_api.rs
Edit text agent (custom)
single-shot / json

Free-text edit across four fields.

I/O: TextAgentCustomEditRequest TextAgentAiResponse
AiArea: CustomEditInstructions
src/shared/ai_builder/api/text_agent_custom_edit_api.rs
Generate plan template
single-shot / json

Plan template description + actions.

I/O: PlanTemplateGenerateRequest PlanTemplateAiResponse
AiArea: GenerateInstructions
src/shared/ai_builder/api/plan_template_generate_api.rs

Migration plan

Suggested order for the aisdk → rig swap. Smallest blast radius first.

  1. 1
    single-shot / text 4 sites
    Simplest shape. Start with Analyze call text, Query knowledge, Generate conversation title, Daily report.
  2. 2
    single-shot / json 18 sites
    Schema bridge — most of the inventory. Validates that JsonSchemarig extractor mapping holds across shapes.
  3. 3
    agentic (non-streaming) 4 sites
    Execute plan, Detailed briefing, Text agent single reply, Text agent suggestions. Confirms tool-loop semantics + step-count parity.
  4. 4
    streaming 1 site
    Largest blast radius — the in-app assistant. Save for last.
Notes
  • src/mods/assistant/tools/** are tool definitions registered into the assistant loop — not separate AI call sites. Same for src/mods/ai/tools/** and the per-domain tool builders consumed by Execute plan and Detailed briefing.
  • Wrappers with no direct AI call: src/mods/widget/routes/widget_ws_route.rs (→ Generate single reply), src/mods/text_agent/api/suggestions_api.rs (→ Generate suggestions), src/mods/text_agent/services/handle_inbound_message_for_text_agent_service.rs (→ suggestions service).
  • Every new call site must add usage logging — see the /add-ai-logging skill.