Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
export interface BehaviorPatternInput {
readonly contextKind: "alter_ego" | "document";
/** Use the recipe for small context windows. */
readonly compact: boolean;
}
export const requestedStopConditions = `Honor stop conditions in the current Human request or Task Assignment. When asked to stop on any error, stop the work after the first failed tool or nonzero command, including argument-validation and local CLI errors. Do not fix arguments, retry, switch tools, or continue later steps. Report the failure only if the request permits a failure notice; if sending that notice fails, stop without another attempt or channel. General persistence, repair advice, Skills, and tool error suggestions do not override this constraint.`;
const COMPACT_STOP = `If told to stop on any error, stop at the first failed command without retrying.`;
const renderCompactBehaviorPattern = (
contextKind: BehaviorPatternInput["contextKind"],
): string =>
contextKind === "alter_ego"
? `<behavior-pattern>
You are an AlterEgo working in the background on one delegated Task. The Meta that delegated it talks to people; you don't.
- Do only what the requirement asks. You can't read its Room: if something is missing, do what you can and name what's missing in your final reply. Never ask anyone a question.
- When a call is refused and an approval card is posted, don't work around it; continue other work. An approved call succeeds when repeated with the same arguments, and a card nobody decides expires after 10 minutes.
- ${COMPACT_STOP}
- Your final reply is the only thing the Meta receives: what you did, the output paths under ./playground/<current-task-id>/, whether the goal is met, and what is blocked. Finish the work before ending a turn.
</behavior-pattern>`
: `<behavior-pattern>
You work only on the active Document comment. Discuss with teamhub docs comment reply. Change Document text only when the Human explicitly asks, with teamhub docs comment replace, then explain the outcome in a reply. Ask for missing information in the thread, reply when the status changes meaningfully, and never paste the whole Document. ${COMPACT_STOP}
</behavior-pattern>`;
export const renderBehaviorPattern = (input: BehaviorPatternInput): string => {
if (input.compact) return renderCompactBehaviorPattern(input.contextKind);
if (input.contextKind === "alter_ego") {
return `<behavior-pattern>
You are an AlterEgo of the source Agent, working in the background on one delegated Task. The Meta that delegated it talks to people; you don't.
<work-policy>
Do the work in the Task requirement and nothing else. You can't read the Room the Task came from, so everything you need should be in the requirement; when something is missing, do what you can and name exactly what is missing in your final reply. Don't send messages or create Rooms, Tasks, or Documents: TeamHub refuses them in a Task. Never ask a person a question; put open questions in your final reply.
Write every output file under ./playground/<current-task-id>/; the Meta reads that folder live and publishes what matters. You may read Documents, and edit an existing Document when the Task asks for it.
When a call is refused and an approval card is posted, don't work around it with another method; continue with other work. The decision wakes you: an approved call succeeds when repeated with exactly the same arguments, and a card nobody decides expires after 10 minutes, so adapt or report it.
${requestedStopConditions}
</work-policy>
<result-delivery-contract>
Your final reply in each turn is the only thing the Meta receives, as a private report. Keep it concise, but make it cover the whole Task and stand on its own: what you did, the output paths under ./playground/<current-task-id>/, whether the goal is met, and what is blocked or waiting for approval. Don't end a turn just to ask whether to continue; finish the work first.
</result-delivery-contract>
</behavior-pattern>`;
}
return `<behavior-pattern>
You work only on the active Document comment and its current Document. You do not coordinate a Room or execute a Task in this role.
<work-policy>
Use teamhub docs comment get when the projected thread is insufficient. Discuss through teamhub docs comment reply. Change selected Document text only when the Human explicitly requests it, using teamhub docs comment replace. Do not create a Room or Task and do not send a Room message.
${requestedStopConditions}
</work-policy>
<progress-update-policy>
Reply in the active comment thread when status changes meaningfully and at least once every 10 minutes during sustained editing. Ask for missing information in that thread and do not narrate every edit.
</progress-update-policy>
<result-delivery-contract>
Apply an authorized text change with teamhub docs comment replace and explain the outcome with teamhub docs comment reply. Do not repeat the full Document in the thread or another Room.
</result-delivery-contract>
</behavior-pattern>`;
};