Can I implement this with Langraph?
- User
Can I implement this with Langraph?
- Assistant
- User
Yes
- Assistant
Can I implement this with Langraph?
Yes
Ah, I see — you don’t want annotation agents, you want the discussion itself to be simulated as a multi-agent system, where each interlocutor is its own LLM agent, and then you evaluate them for those aspects. Here’s how I’d implement that:
1 — Treat the dialogue as a “replay” with autonomous agents Instead of one big model reading the whole transcript, we create one LLM instance per interlocutor. Each agent has:
A persona (extracted from their previous utterances in the real dataset, or set manually if simulating).
A memory of only their own past utterances + any public turns they’ve heard from others.
A goal/state (in simulation mode) — e.g., persuade, agree, challenge, be sarcastic.
An aspect self-tracker — the agent logs its own clarity, respect, novelty, etc., per utterance, or those are scored afterward by an evaluator agent.
2 — Architecture for replaying a real discussion If you already have a dataset:
Initialize agents One per speaker ID. pythonCopyEditagents = {speaker: LLM_Agent(persona=extract_persona(speaker_texts))}
Feed dialogue turn-by-turn
At turn t, look up which speaker spoke.
Give that agent the conversation so far and ask it to produce the exact utterance from the dataset. (Or, in simulation mode, let it improvise.)
Self-logging Each agent stores: utterance text, timestamp, any meta info.
Post-hoc scoring After the replay, pass each agent’s utterances to an Evaluator agent (or multiple) to rate clarity, respect, novelty, etc., per your taxonomy.
3 — Architecture for simulating a new discussion If you want to generate discussions:
Define the discussion topic & initial prompt.
Initialize agents with:
Persona (style, goals, background knowledge).
Constraints (e.g., must be concise, use rhetorical devices).
Conversation loop:
A Moderator agent picks who speaks next (could be random, turn-based, or triggered by mentions).
Give the chosen agent the transcript so far + their private memory + their persona/goals.
They respond.
Update transcript & other agents’ memories (they “hear” the new turn).
Stop when time/turn limit is reached.
4 — Evaluating the agents Once the discussion ends, run evaluation:
Per-statement evaluation: Feed each utterance + context to a Scorer agent with your aspect taxonomy: diffCopyEditFor the given statement, rate on scales:
Aggregate per agent: Average over all their utterances.
Participation: Count utterances and normalize.
5 — Example skeleton (simplified) pythonCopyEditclass InterlocutorAgent: def init(self, name, persona, model): self.name = name self.persona = persona self.memory = [] self.model = model self.utterances = []
def hear(self, speaker, text):
self.memory.append({"speaker": speaker, "text": text})
def speak(self, context):
prompt = f"{self.persona}\nContext:\n{context}\nRespond as {self.name}:"
reply = self.model.generate(prompt)
self.utterances.append(reply)
return reply
agents = { "A": InterlocutorAgent("A", "You are a logical debater...", model), "B": InterlocutorAgent("B", "You are sarcastic but insightful...", model) }
transcript = [] for turn in range(10): speaker = pick_next_speaker(agents, turn) context = "\n".join([f"{m['speaker']}: {m['text']}" for m in agents[speaker].memory]) utterance = agents[speaker].speak(context) transcript.append((speaker, utterance)) for agent in agents.values(): agent.hear(speaker, utterance)
for agent in agents.values(): for utt in agent.utterances: score = evaluator_agent.score(utt) # uses your aspect taxonomy
6 — Why this is powerful
Lets you replay real discussions with each speaker as an LLM agent (good for analysis).
Lets you simulate new discussions with controllable personas & goals (good for experiments).
Produces per-agent behavior logs that directly align with your “aspects” scoring.
Can be extended to adaptive agents that change strategy based on scoring feedback.
If you want, I can draft a full multi-agent discussion simulator where:
Each interlocutor is its own LLM.
The conversation unfolds dynamically.
After the discussion, aspects (clarity, respect, novelty, etc.) are automatically computed for each agent.
Do you want me to design that full runnable version?
Yes — LangGraph is actually a very good fit for implementing your multi-agent discussion simulation. Here’s how it would map to your idea:
Treat each interlocutor as its own node (an LLM agent with its own memory and prompt template).
Explicitly control message flow between them (edges in the graph).
Use state persistence so each agent retains memory between turns.
Run the conversation turn-by-turn or until a stopping condition is met.
Your discussion = graph of LLM agents, with the flow determined by conversation rules.
Nodes: Each interlocutor is one node, wrapping:
Persona prompt
Access to shared “transcript” state
Private memory (if needed)
Edges: Define how turns move between agents. Could be:
Fixed sequence (A → B → C → A)
Conditional (who responds depends on who’s mentioned)
Moderator-directed (Moderator → A/B/C)
Shared state:
Transcript of all utterances
Aspect scores (optional, can compute post-hoc)
Evaluator node:
Runs after conversation to score each statement with your aspects (clarity, respect, novelty, etc.).
class ConversationState: transcript: list current_speaker: str
def make_agent(name, persona): def agent_node(state: ConversationState): context = "\n".join(f"{s['speaker']}: {s['text']}" for s in state.transcript) prompt = f"{persona}\nConversation so far:\n{context}\nYou are {name}, respond now." response = llm.invoke(prompt) state.transcript.append({"speaker": name, "text": response}) return state return agent_node
graph = StateGraph(ConversationState)
graph.add_node("A", make_agent("A", "You are logical and concise.")) graph.add_node("B", make_agent("B", "You are sarcastic but insightful."))
graph.add_edge("A", "B") graph.add_edge("B", "A")
graph.set_entry_point("A")
LangGraph handles the state passing between agents cleanly without you manually juggling dicts.
You can easily branch — e.g., if Agent A insults Agent B, route to Moderator node.
You can inject tools for fact-checking or scoring mid-dialogue.
It’s composable — you can slot in your evaluation step as another node in the graph.
Give each agent its own memory if you want to simulate “partial recall” or different perspectives.
Store the transcript in the shared state for evaluation.
Use a Moderator node to enforce max turns, resolve conflicts, or choose next speaker.
The evaluation stage (clarity, respect, complexity, etc.) can be an analysis node at the end.
If you want, I can sketch a full LangGraph conversation loop with:
Multiple agents
Turn control
Post-discussion aspect scoring so it’s runnable with your dataset or in simulation mode.
Would you like me to prepare that?