Identity preservation
When context compression fires, the teammate loses its system prompt, including who it is, its role, and its team. The make_identity_block function creates a user message with identity tags that gets injected after compression. The agent knows who it is again.
def make_identity_block(name: str, role: str, team_name: str) -> dict:
return {
"role": "user",
"content": f"<identity>You are '{name}', role: {role}, "
f"team: {team_name}. Continue your work.</identity>",
}Three lines that preserve agent identity across context compression.
AI prompt: Try it: Multi-agent task
Loading practice…
Quiz: Quiz
Loading practice…