How to Build a Great AI Agent: A Developer's Guide to English Teaching Applications
A practical guide to building AI agents for English speaking practice and assessment. It covers distinguishing practice from evaluation, conversation orchestration with state machines, real-time voice pipeline design, tool contracts, scoring calibration, memory systems, and launch validation—helping developers turn chat interfaces into reliable, verifiable learning applications.
1. Start Here: A Great Agent Solves Ongoing Tasks, Not Single-Turn Q&A
The most common pitfall when developing AI agents is treating “hook up an LLM, write a role prompt, add a chat interface” as a complete solution. Such a system can answer questions, but it may not reliably complete teaching tasks.
Take spoken English training as an example. The user needs more than a reply—the system must assess the current proficiency level, choose appropriate topics, identify expression difficulties, control the pacing of corrections, and deliver credible improvement suggestions after the session. Assessment scenarios further require reasonable topic coverage, explainable difficulty changes, and traceable scoring rationale.
A more sound system model is:
User input → perception and understanding → conversation state evaluation → teaching or assessment decision → tool execution → response generation → feedback and memory update.
In this model, the LLM handles language understanding, expression generation, and part of the reasoning. Task boundaries, state transitions, permission control, and data consistency should be guaranteed by deterministic engineering mechanisms.
Judging whether an agent is excellent should not rely solely on response fluency. Also consider task completion, scoring reliability, interaction experience, safety boundaries, and operating cost.
2. Business Design: Separate Practice from Assessment, Then Define Success
1. Practice and assessment should not share one default strategy
The goal of speaking practice is to encourage expression. The system should prompt full sentences, ask follow-up questions around user interests, and prioritize correcting issues that affect comprehension or recur frequently. Densely correcting every sentence tends to break conversational flow.
The goal of proficiency assessment, by contrast, is to collect sufficient evidence of ability. The system must control the topic scope, limit the degree of prompting, distinguish independent expression from assisted expression, and generate results according to explicit scoring rules.
The two modes can share speech processing and basic tools, but should be configured separately for:
- Conversation strategy: open exchange vs. constrained ability sampling.
- Correction timing: immediate hints, stage-based prompts, or unified feedback after assessment.
- Level of assistance: whether translation, sample answers, or vocabulary hints are allowed.
- Exit conditions: completing practice goals vs. gathering sufficient assessment evidence.
- Reporting scope: learning suggestions vs. a proficiency estimate with clearly stated applicability.
If the mode boundary is unclear—for example, a user receives hints during assessment and continues answering—the system may overestimate their independent ability.
2. Turn abstract goals into observable metrics
“Improve English proficiency” is too broad to guide development. Break it down into verifiable targets, such as:
- Whether users sustain effective conversation.
- Whether training covers the intended knowledge points.
- Whether correction suggestions are accurate, understandable, and actionable.
- Whether assessment results show reasonable agreement with human evaluation.
- Whether the system remains usable under network failures or tool errors.
- Whether users can proceed to the next exercise, not just read a report.
Metrics should also distinguish process from outcome. Longer speaking time reflects engagement but does not directly prove proficiency gains; a higher report generation rate does not mean scoring is accurate.
3. Define the competency framework and its boundaries
Competency standards should use interpretable descriptions—for example, whether the user can complete simple information exchange, narrate experiences coherently, or state an opinion and respond to challenges.
If results need to map to common language proficiency levels, state the mapping basis and its limitations. A short conversation can only observe limited abilities; it cannot replace a full exam or justify definitive judgments about all language skills.
3. Conversation Orchestration: Manage Flow with a State Machine, Handle Language with the Model
1. Define inputs, actions, and exits for each stage
Break the session into stages such as preparation, initial evaluation, topic exchange, targeted follow-up, summary feedback, and closing. For each stage, specify:
- What information to collect.
- Which tools may be used.
- Which teaching constraints must be followed.
- Under what conditions to move to the next stage.
- How to recover from anomalies.
- The maximum number of turns or duration allowed.
For example, the initial evaluation stage should not immediately output a precise level. Its job is to gather the user’s expression length, comprehension, and baseline language performance, forming a provisional difficulty estimate.
The topic exchange stage should record covered topics and competency points to avoid repeating questions. Targeted follow-ups should target competencies with insufficient evidence, rather than mechanically adding more questions.
2. Separate business decisions from response generation
Deciding “what to do next turn” first, then generating “how to say it naturally,” is usually more stable than letting the model freely handle everything at once.
Here is an illustrative internal decision structure, not a product interface:
Current stage: Topic exchangeTurn goal: Observe whether the user can explain reasonsNext action: Follow up on the user's previous pointDifficulty adjustment: MaintainCorrection policy: No interruption; log key errorsAllowed tools: Expression analysisExit condition: Re-evaluate evidence coverage after a valid answer
The business layer should validate action legality. For example, the model must not output a final score before the assessment ends, and must not claim pronunciation analysis is complete before the tool returns results.
3. Set dedicated handling paths for abnormal inputs
Long silences, empty recognition results, repeated topic-change requests, or off-topic answers should not automatically trigger ordinary follow-ups.
Strategies may include limited retries, restating the question, reducing task complexity, or proactively ending the current segment. State transitions should record the cause, so later you can determine whether the problem came from user behavior, recognition quality, or decision logic.
4. Real-Time Voice: Prioritize Continuity and Interruptibility
1. Treat voice interaction as a continuous pipeline
A typical voice pipeline looks like:
Audio capture → echo cancellation and noise reduction → voice activity detection → streaming speech recognition → decision and text generation → streaming speech synthesis → audio playback.
Voice activity detection determines when the user starts and stops speaking, but it must not treat every brief pause as the end of an answer. English learners often pause to organize their thoughts; cutting them off too early noticeably degrades the experience.
Decide end-of-speech by combining silence duration, recognition text completeness, and current task characteristics. For long-answer scenarios, also provide an explicit “done speaking” action as a supplement.
2. Distinguish interim recognition results from final results
Interim text from streaming recognition is continuously revised. The interface can display interim text, but scoring, persistence, and critical state transitions should use confirmed results.
Otherwise, the system may correct words that are not yet finalized, or count content the recognizer later revises as user errors.
3. Interruption support must run through the whole system
When the user starts speaking while the agent is playing audio, simply stopping the player is not enough. The system must also cancel stale generation tasks, clear queued audio, and prevent old tasks from sending replies after completion.
Assign a task identifier to each interaction turn. When the user interrupts, a new task replaces the old one; any tool result returned afterward must be checked against the currently valid turn.
4. Monitor latency in segments, not as one number
Natural conversation does require low latency, but real-world performance depends on network conditions, recognition approach, model inference, tool latency, and playback strategy.
Record elapsed time separately from the user finishing speech to recognition confirmation, decision completion, and first audio playback, and examine the distribution of slow requests. Optimization usually focuses on reducing serial tool calls, reusing connections, streaming generation, and moving non-critical analysis to the background.
Never present a “please wait” message as an effective answer in pursuit of speed, and never generate scores before the evidence is complete.
5. Tools and Evaluation: Turn “Language Opinions” into Verifiable Feedback
1. Handle text analysis and acoustic analysis separately
A text model can analyze vocabulary, syntax, and discourse organization, but transcription alone cannot reliably judge phoneme pronunciation, stress, or intonation.
Acoustic evaluation should be based on audio and corresponding analysis results. For read-aloud tasks, a reference text can help locate deviations; for free expression, you must deal with transcription errors, accent variation, and alignment uncertainty.
Analysis results should carry quality metadata. When background noise is high, audio is too short, or recognition confidence is low, soften conclusions or suggest re-recording instead of outputting seemingly precise scores.
2. Tool calls need explicit contracts
Each tool should define input fields, output structure, timeout policy, error types, and applicable scenarios. Tool outputs must also be validated and never concatenated directly into the final reply.
For example, a correction result should include at least the original expression, the problem location, a suggested revision, an explanation, and conditions of use. An expression that is merely “not natural” should not be flagged as a definite grammar error.
If the pronunciation tool is unavailable, the system can continue text-based conversation, but it must state that reliable pronunciation analysis was not performed this turn—text performance must not substitute for acoustic conclusions.
3. Background analysis is not the same as immediate correction
The main conversation flow maintains the interaction; background tasks detect issues; the two should coordinate through structured events.
Issues suitable for immediate prompting include expressions that severely impair comprehension. General errors, recurring grammar problems, and suboptimal phrasing can be batched into stage reviews.
Each feedback round should focus on a few high-value issues and provide directly actionable exercises. “Explain one problem, demonstrate once, let the user try again” creates a better learning loop than listing a dozen errors.
6. Scoring Calibration: Keep Conclusions Consistent with Evidence
1. Establish dimension-specific scoring rules
Evaluate dimensions separately: coherence, vocabulary use, grammar control, task completion, and—when audio quality permits—pronunciation.
Each dimension needs clear descriptors and typical examples. The scoring module should collect evidence first, determine the band by rule, and generate the explanation last—rather than producing a total score first and writing rationale backward.
Structured output constrains format only; it does not guarantee correct evaluation. The system still needs checks on evidence citation, score ranges, and explanation consistency.
2. Preserve “insufficient evidence” and uncertainty
“No errors observed” does not mean “mastery proven.” If the user only produced one simple answer, the system should not draw high-confidence conclusions about complex-sentence ability.
Reports should distinguish observed abilities, uncovered abilities, and results affected by data quality. Recommend a follow-up assessment when necessary instead of forcing a complete level output.
3. Calibrate automated scoring with human-labeled samples
Prepare samples covering different proficiency levels, expression styles, accents, and audio quality, labeled by qualified personnel following unified rules.
During evaluation, look beyond average error: check whether certain answer types are systematically overrated, whether specific accents are judged too harshly, and whether repeated scoring of the same answer is stable.
For suspected memorized answers, vary the situation, ask for reasoning, or request specific personal experiences to increase observation of ability—do not conclude cheating based on fluency alone.
7. Memory System: Store Learning Evidence, Not Unlimited Chat Logs
1. Short-term memory serves the current task
Short-term memory may include the current topic, questions already asked, stage goals, summaries of recent answers, and the provisional difficulty estimate. It should update with the conversation in real time and be cleared by policy after the session ends.
When compressing context, prioritize information that affects subsequent decisions—such as whether the user received hints and which competency points have been covered—rather than just keeping a conversation digest.
2. Long-term profiles serve cross-session learning
Long-term profiles are suitable for recording recurring error types, exercise completion, user preferences, and confirmed learning goals.
Each record should carry its source, timestamp, occurrence count, and confidence level. A one-off mistake should not permanently become a “weak point,” and profiles should adjust as new evidence arrives after the user corrects an error.
Structured data suits stable fields; semantic retrieval helps find relevant historical fragments—but retrieval results still need checks for staleness, ownership, and relevance to the current turn.
3. Privacy governance must start at design time
Audio, transcripts, and learning profiles may all contain personal information. The system must define collection purposes, retention periods, access permissions, and deletion mechanisms.
Non-essential information should not enter long-term memory. Raw audio and derived scores can follow different retention policies; data used for analysis or evaluation should be de-identified according to actual needs. Additional consent management and content protection apply when minors are involved.
8. Launch Validation: Test Effectiveness, Safety, and Operability Together
1. Offline tests should cover the full task chain
Testing should not check only model replies. Cover state transitions, tool parameters, timeout recovery, duplicate requests, user interruptions, and report consistency.
Include adversarial inputs: users asking to ignore assessment rules, tools returning abnormal content, or retrieved snippets carrying embedded instructions. Both user text and external tool results must be treated as data, never automatically granted permission to modify system rules.
2. Online monitoring should correlate whole interaction turns
Create correlation identifiers across sessions, turns, and tool calls. Record per-stage latency, recognition failures, cancelled tasks, tool errors, and state changes.
Avoid exposing full audio or sensitive text in logs unnecessarily. Troubleshooting requires traceability, but not at the cost of over-collection.
3. Prepare degradation paths for critical dependencies
If speech recognition fails, guide the user to retry or switch to text input. If acoustic evaluation fails, suspend the related scores. If long-term memory is unavailable, maintain the current session while clearly noting that personalization is limited.
The basic principle of degradation: reduce capability scope rather than fake completion states; preserve user progress so failures do not turn into endless retries.
4. Expand gradually from a minimal closed loop
A first release might cover only a few topics, a fixed teaching flow, text or basic voice interaction, key error feedback, and a brief review.
Once the flow is stable, add real-time interruption, adaptive difficulty, acoustic evaluation, long-term memory, and more complex combined analysis. Every added capability should come with matching tests, monitoring, and failure recovery.
9. Conclusion: Great Agents Come from Verifiable Closed-Loop Engineering
Building an AI English-teaching agent is not about stacking more models or longer prompts. It is about turning teaching goals into explicit processes, turning model judgments into traceable evidence, and turning interaction problems into recoverable engineering mechanisms.
A reliable system should know what the current task is, why the next step is taken, what tool results can actually prove, which conclusions remain uncertain, and what the user should practice next.
Only when perception, decision-making, execution, feedback, and memory form a genuine closed loop can an agent grow from a “chat interface” into an application that continuously helps users complete learning tasks.
