I'm doing interviews by ai, but the context is too...
# ask-ai
s
I'm doing interviews by ai, but the context is too big, i want to context better, so was thinking to have agent for each main question, or what do you recommend?
✅ 1
t
Thanks for reaching out, Mostafa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I hear you: your interview session context is getting too big and you’re wondering whether to give each main question its own agent or use a different pattern. I’ll summarize the options and give a clear recommendation plus practical next steps. Short recommendation • Don’t start with one agent per question. Use structured tasks (AgentTask + TaskGroup) or a supervisor/specialist pattern only if you need it. These keep context small, are easier to manage, and give the same benefits as per-question agents without the extra complexity. Why (quick): • One agent per question increases orchestration complexity and latency. • Task-based flows let each question run in a focused context, return typed results, and hand control back to the main flow. • A supervisor + specialists pattern is a good follow-up if you need specialized personas or tooling per topic. Concrete approaches to choose from • TaskGroup + AgentTask (best first approach) ◦ Create an
AgentTask
for each main interview question (e.g., TechnicalTask, BehavioralTask). ◦ Group them in a
TaskGroup
so the interview runs step-by-step and you get structured results at the end. ◦ Use
userdata
for persistent session info (candidate name, metadata, collected answers). • Supervisor + Specialist agents (when to use) ◦ Use when a question requires deep, domain-specific reasoning or specialized tools. ◦ The supervisor routes the conversation to a specialist and then synthesizes answers. ◦ Good for complex or multi-modal interviews, but adds latency and orchestration work. How to keep context small (practical tips) • Summarize between steps: after each question/task, produce a short structured summary and pass that summary, not the full transcript, into the next task. • Avoid copying system prompts or large instruction payloads between tasks (copy context excluding instructions). • Store persistent state in a compact
userdata
object rather than embedding long transcripts into prompts. • Return typed or structured results from tasks (e.g., score, key points, follow-ups) to make downstream decisions easier. Suggested minimal implementation flow 1. IntroTask: collect candidate metadata, short context. 2. TaskGroup: a. TechnicalTask -> returns
TechnicalResult
(answers, score, topics to probe) b. BehavioralTask -> returns
BehavioralResult
c. CultureFitTask -> returns
CultureResult
1. Summarizer task: build a final concise summary and candidate report from the task results. When to escalate to supervisor + specialists • If tasks repeatedly need very different system instructions, tools, or specialized reasoning. • If you need real-time handoffs between voice modules or external tool calls for each question. If you want, I can: • Sketch a minimal example of an
AgentTask
+
TaskGroup
flow you can drop into your code. • Show an example summarization prompt that keeps context under control. • Help pick which questions to convert into tasks first (start with the 3–5 highest-value questions). Which of the three follow-ups would help you most right now: a code-style example, a summarization prompt, or help mapping your current questions into tasks? Sources: How to Use the Supervisor Pattern for Multi-Agent Voice AI Systems | LiveKi... | Building multi-agent architectures with LiveKit agents | LiveKit | The Handoff Pattern for Voice Agents That Replaces IVR Menus | LiveKit | Tasks and task groups | LiveKit Documentation | Collect recording consent with tasks | LiveKit Documentation, with interactive elements
s
i like this approach, TaskGroup + AgentTask (best first approach) detail what we have to do
t
Great — let’s walk through a clear, actionable plan to implement the TaskGroup + AgentTask approach for your AI interview flow. I’ll break this into design decisions, a step-by-step implementation plan, code-style examples, and best-practice checks you can use as you prototype. What we’re building • A multi-question interview that keeps context small by running each main question as an
AgentTask
. • A
TaskGroup
to sequence tasks, collect typed results, and produce a final summary/report. • Compact persistent state in
userdata
and short summaries between tasks. High-level design • AgentTask = focused unit that asks one question (or a closely related set), collects the candidate’s response, scores/labels it, and returns a typed result. • TaskGroup = ordered sequence of AgentTasks (Intro, Technical, Behavioral, Culture, Wrap-up). • Summarizer = combines results into final report; stores small summaries in
userdata
. • Supervisor (optional) = routes to specialist tasks if you later need domain-specific logic. Step-by-step implementation plan 1. Define data models (typed results) ◦ For each question/task, define a result type. Example fields:
answer_text
,
score
,
key_points
,
follow_up_questions
. 1. Implement AgentTask classes ◦ Each task should: i. Receive minimal context (candidate id, prior brief summary). ii. Ask the question(s). iii. Capture response, extract structured outputs (score, tags). iv. Return the typed result. 1. Implement TaskGroup orchestration ◦ Create a TaskGroup and add tasks in the interview order. ◦ Ensure
userdata
holds persistent small state: candidate metadata, cumulative summary, and task outputs. 1. Summarization between tasks ◦ After each task completes, create a 1–3 sentence summary (or structured bullet points) and store in
userdata
. ◦ Pass only the summary and necessary metadata to the next task. 1. Final summarizer/report task ◦ Aggregate typed results from tasks into a final candidate report and recommended next steps. 1. Logging and storage ◦ Persist typed results and final report in your database for later retrieval or re-evaluation. 1. Iteration and monitoring ◦ Start with 3–5 core tasks, evaluate latency and accuracy, expand or convert tasks to specialists only if necessary. Code-style examples (pseudo-Python to illustrate structure) 1) Result types (dataclasses)
Copy code
from dataclasses import dataclass
from typing import List

@dataclass
class QuestionResult:
    answer_text: str
    score: int  # e.g., 1-5
    key_points: List[str]
    follow_ups: List[str]
2) Example AgentTask (conceptual)
Copy code
class TechnicalTask(AgentTask[QuestionResult]):
    def __init__(self):
        super().__init__(instructions="Ask a technical systems-design question and evaluate clarity, correctness, and approach.")

    async def run(self, chat_ctx):
        # 1. Pull compact session summary and candidate metadata
        session_summary = chat_ctx.userdata.get("session_summary", "")
        candidate = chat_ctx.userdata.get("candidate_name", "Candidate")

        # 2. Ask the question (system/prompt)
        question = "Describe how you'd design a scalable pub/sub system. Walk through components and trade-offs."
        await chat_ctx.send_user_message(question)

        # 3. Wait for and capture response
        response = await chat_ctx.wait_for_user_response()

        # 4. Extract structured evaluation (could be done with an LLM evaluation helper)
        score = score_answer(response)  # custom function or small evaluator
        key_points = extract_key_points(response)
        follow_ups = generate_follow_ups(response, score)

        result = QuestionResult(
            answer_text=response,
            score=score,
            key_points=key_points,
            follow_ups=follow_ups
        )

        # 5. Update userdata with concise summary
        summary = f"TechQ: score={score}; key={', '.join(key_points[:3])}"
        chat_ctx.userdata["session_summary"] = merge_summaries(chat_ctx.userdata.get("session_summary",""), summary)

        return result
3) TaskGroup orchestration (conceptual)
Copy code
task_group = TaskGroup()
task_group.add(lambda: IntroTask(), id="intro")
task_group.add(lambda: TechnicalTask(), id="technical")
task_group.add(lambda: BehavioralTask(), id="behavioral")
task_group.add(lambda: CultureFitTask(), id="culture")
task_group.add(lambda: WrapupTask(), id="wrapup")

results = await task_group.run(chat_ctx)
# results will be structured by task ids
final_report = await SummarizerTask().run_with(results, chat_ctx)
store_in_db(candidate_id, results, final_report)
Summarization pattern (between tasks) • Keep it short: 1–3 sentences, or a few structured fields. • Example summary structure: ◦ last_question: "TechnicalQ1" ◦ top_points: ["scalable queue", "partitioning", "trade-offs on consistency"] ◦ overall_score: 4 Use this summary as the only context for next task (plus
userdata
fields like candidate name). Evaluation & scoring • Keep scoring rules consistent. Use a small rubric per task: ◦ Technical: correctness (0–2), system thinking (0–2), trade-offs (0–1) -> sum into 0–5 ◦ Behavioral: STAR structure, clarity, examples -> 0–5 • Return scores in the typed result to ease final aggregation. Best-practice tips • Start small: prototype with 3 tasks (Intro, One Technical, Behavioral). • Use deterministic evaluation prompts or small heuristics where possible to keep outputs consistent. • Avoid copying system instructions from task to task; keep the system-level prompt minimal. • Store transcripts separately from
userdata
so
userdata
stays compact. • If a task routinely needs additional tools or domain knowledge, consider turning it into a specialist agent later. • Monitor latency: TaskGroup reduces context size but has orchestration overhead—measure round-trip times. What I can help with next • Provide a concrete summarization prompt and example summarizer implementation. • Convert two of your existing interview questions into
AgentTask
skeletons. • Provide a sample rubric for scoring technical and behavioral tasks. Which would you like me to draft now: a code-ready summarizer prompt, two AgentTask skeletons for your specific questions, or a scoring rubric for the tasks? , with interactive elements