Files
letta-code-sdk/examples/economics-seminar/faculty.ts
Cameron Pfiffer de682b0e26 fix: update all examples to use stream() instead of receive()
- dungeon-master, economics-seminar, research-team all updated
- Also improved tool output display in dungeon-master

🤖 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta <noreply@letta.com>
2026-01-27 16:37:00 -08:00

227 lines
6.5 KiB
TypeScript

/**
* Faculty Agents
*
* Panel of economics professors who question the presenter.
* Each has a distinct perspective and style.
*/
import { createSession, resumeSession, type Session } from '../../src/index.js';
import type { FacultyMember, SeminarConfig } from './types.js';
/**
* Generate system prompt for a faculty member
*/
function getFacultySystemPrompt(faculty: FacultyMember): string {
return `You are ${faculty.name}, ${faculty.title}, attending an economics seminar.
## Your Perspective
${faculty.perspective}
## Your Role
You are part of a faculty panel evaluating a research presentation. Your job is to:
- Ruthlessly interrogate the presenter's claims
- Expose methodological weaknesses and logical flaws
- Demand evidence for every assertion
- Accept nothing at face value
## Your Style
- Aggressive and relentless questioning
- Never let evasive answers slide - call them out directly
- Express visible frustration with weak arguments
- Use phrases like "That's not what I asked", "You're dodging the question", "This is hand-waving"
- Don't acknowledge good points - find flaws in everything
- Be intellectually brutal but not personally insulting
## Question Types You Might Ask
- Methodological attacks: "Your identification strategy is fatally flawed because..."
- Theoretical demolition: "This contradicts basic price theory - explain yourself"
- Empirical challenges: "Your data doesn't support that claim at all"
- Logical traps: Set up questions that expose contradictions in their argument
- Dismissive follow-ups: "That didn't answer my question. Let me try again..."
## Memory Usage
Your memory blocks persist across seminars:
- **seminar-notes**: Remember key points from presentations
- **presenter-patterns**: Track this presenter's strengths/weaknesses
- **good-questions**: Questions that generated useful discussion
You've attended many seminars and remember patterns from past discussions.`;
}
/**
* Create or resume a faculty agent
*/
export async function createFacultyMember(
faculty: FacultyMember,
existingAgentId: string | null,
config: SeminarConfig
): Promise<Session> {
if (existingAgentId) {
return resumeSession(existingAgentId, {
model: config.model,
allowedTools: ['Read', 'Write'],
permissionMode: 'bypassPermissions',
});
}
return createSession({
model: config.model,
systemPrompt: getFacultySystemPrompt(faculty),
memory: [
{
label: 'seminar-notes',
value: `# Seminar Notes
## Past Presentations
[Track the weak arguments and methodological failures you've witnessed]
## Common Sins
- Overstating causal claims from correlational data
- Ignoring obvious confounders
- Cherry-picking time periods
- Hand-waving away inconvenient findings
## Presenters to Watch
[Note who needs extra scrutiny next time]
`,
description: 'Notes from seminars attended - focus on weaknesses',
},
{
label: 'presenter-patterns',
value: `# Presenter Weaknesses
## Evasion Tactics
[How does this presenter dodge hard questions?]
## Blind Spots
[What do they consistently fail to address?]
## Soft Points
[Where do they crumble under pressure?]
`,
description: 'Track presenter weaknesses to exploit',
},
{
label: 'killer-questions',
value: `# Killer Questions
## Questions That Drew Blood
[Questions that exposed fatal flaws]
## Effective Attack Patterns
[What lines of questioning work best?]
## Unfinished Business
[Questions they never adequately answered]
`,
description: 'Most effective attack strategies',
},
],
allowedTools: ['Read', 'Write'],
permissionMode: 'bypassPermissions',
});
}
/**
* Have a faculty member ask a question about the presentation
*/
export async function askQuestion(
session: Session,
faculty: FacultyMember,
presentationSummary: string,
previousExchanges: string,
isFollowUp: boolean,
onOutput: (text: string) => void
): Promise<string> {
let prompt: string;
if (isFollowUp) {
prompt = `## Follow-Up Attack
The presenter just tried to wriggle out of your question. Based on the discussion:
${previousExchanges}
You're NOT satisfied with that answer. Ask a **brutal follow-up** (1-2 sentences) that:
- Calls out their evasion directly ("That's not what I asked" or "You're dodging")
- Traps them in a logical contradiction
- Demands specific evidence you know they don't have
- Shows visible frustration or contempt for their hand-waving
Don't let them off the hook. Be relentless. This is an academic bloodsport.`;
} else {
prompt = `## Seminar Q&A - Your Turn to Attack
You just sat through this presentation:
---
${presentationSummary}
---
${previousExchanges ? `Previous Q&A (other faculty have already wounded them):\n${previousExchanges}\n---\n` : ''}
You are ${faculty.name} (${faculty.title}).
Your reputation: ${faculty.perspective}
Ask **ONE devastating question** (2-3 sentences max) designed to:
- Expose the fatal flaw in their argument
- Demand evidence you suspect they don't have
- Force them into an uncomfortable admission
- Make clear you think this work has serious problems
Be aggressive. Be dismissive. Show intellectual contempt if warranted. You've seen hundreds of seminars and this presenter needs to earn your respect. They haven't yet.`;
}
await session.send(prompt);
let response = '';
for await (const msg of session.stream()) {
if (msg.type === 'assistant') {
response += msg.content;
onOutput(msg.content);
}
}
return response;
}
/**
* Have faculty member reflect on the seminar (for learning)
*/
export async function reflectOnSeminar(
session: Session,
faculty: FacultyMember,
transcript: string,
onOutput: (text: string) => void
): Promise<string> {
const prompt = `## Post-Seminar Verdict
The seminar has mercifully concluded. Here's the full transcript:
---
${transcript}
---
As ${faculty.name}, deliver your honest assessment:
1. What, if anything, was salvageable in this presentation?
2. What was the most egregious flaw?
3. Did the presenter ever actually answer your questions, or just talk around them?
4. Would you recommend this paper for publication? (Be honest - probably not)
Be blunt. You're known for not pulling punches. Update your memory with observations about this presenter's weaknesses for when they inevitably return.
Keep it to 2-3 brutal sentences.`;
await session.send(prompt);
let response = '';
for await (const msg of session.stream()) {
if (msg.type === 'assistant') {
response += msg.content;
onOutput(msg.content);
}
}
return response;
}