ZacharyZhang-NY 92795f7bfb refactor(session): scope pi sessions to agents instead of tasks
Sessions were keyed by (task, agent). Every task switch started a fresh
transcript — the agent lost everything it had learned on the previous
task. That breaks the product premise: a CEO should remember its past
decisions, an engineer should carry context between bugs.

Move pi's AgentMessage transcript to be agent-scoped. One session per
agent (per company). Tasks enter the ongoing conversation as user turns;
rotation/compaction boundaries follow the agent's long-running session.

Additive schema only — no row rewrites on the live production DB.

- Migration v34: `ALTER TABLE agents ADD COLUMN session_id TEXT` +
  `idx_agents_session_id`. `ensureOptionalColumns` mirror for fresh DBs.
- `AgentRecord.sessionId?: string | null` in the read model; included
  in every full-agent SELECT (entity-crud, snapshot, agents-hierarchy
  chain-of-command / direct-reports / heartbeat-eligible).
- `db.ensureAgentSession({ agentId, companyId, adapterType })` —
  idempotent: returns existing `agents.session_id` if set, else inserts
  a new `task_sessions` row with an empty `task_id` sentinel (agent-
  scoped, task-id is now metadata) and stores the id on the agent.
- `db.setAgentSessionId(agentId, sessionId)` — used by rotation.
- `db.updateTasksActiveSessionForAgent(agentId, sessionId)` — mirrors
  the agent's current session onto every task the agent owns, so
  existing per-task readers (`tasks.active_session_id`) still work.
- `turn-context.resolveSession`: pulls the agent's session via
  `ensureAgentSession` instead of `getActiveTaskSession(task.id)`,
  then points the current task at it so UI continues to resolve.
- `session-management-service.rotateSession`: new session carries
  `taskId:""`, then `setAgentSessionId` + `updateTasksActiveSessionForAgent`
  so every task the agent owns follows the rotation boundary.
- `session-entries.listActive`: `ORDER BY created_at, sequence` — the
  created_at timestamp is authoritative; sequence stays as same-ms
  tiebreaker. Forward-safety for future merge scenarios.

Existing agents' first post-upgrade run creates a fresh agent-scoped
session. Their pre-migration per-task transcripts remain in the DB as
historical records but are not loaded for new runs. This is a one-time
transcript reset, accepted over a risky lossy merge on the live DB.

Documented in a code comment on `ensureAgentSession`.
2026-04-17 15:42:13 -04:00
2026-04-16 14:48:51 -04:00
2026-04-17 14:03:56 -04:00
2026-04-16 14:48:51 -04:00
2026-04-04 12:03:50 -04:00
2026-04-16 14:48:51 -04:00
2026-04-17 14:03:56 -04:00
2026-04-17 14:03:56 -04:00
2026-04-04 12:03:50 -04:00
2026-04-17 14:03:56 -04:00
2026-03-15 22:15:01 -04:00
2026-04-17 14:03:56 -04:00

AgentCompany logo

AgentCompany

Launch autonomous AI companies from your desktop.
Set a goal. Watch AI agents self-organize, delegate, and deliver.
PLEASE USE A CODING PLAN, IT COMSUMES A LOT OF TOKENS
I will add support for Ollama and Github Copilot in the near future.

Latest Release License Platform Electron

Download  |  Website  |  Features  |  Quick Start


AgentCompany Dashboard — active agents, tasks, and company metrics

What is AgentCompany?

AgentCompany is a cross-platform desktop app that turns a single goal into a coordinated AI team. You provide a company name, description, and mission. A CEO agent self-organizes departments, delegates tasks, and produces deliverables — code, content, research, business plans, and more — while you observe and approve through a chat-based command hub. Inspired by Paperclip

Supported AI Runtimes

Runtime Status
Claude Code Ready
Codex CLI Ready
Gemini CLI Ready

Features

Self-Organizing Teams

Your AI CEO builds the org chart — recruiting specialists, creating departments, and establishing reporting lines from a single goal.

Auto-generated org chart with CEO and department heads

Real-Time Agent Communication

Agents coordinate through channel and direct-message threads. Watch decisions unfold in real time.

Real-time messaging between AI agents

Autonomous Task Management

Goals break down into tasks automatically. Agents pick up work, report progress, and escalate blockers without intervention.

Autonomous task queue with goals and status tracking

Human-in-the-Loop Approvals

Critical decisions surface for your review. Approve, reject, or redirect — your company respects the chain of command.

Human approval workflow for agent decisions

AI Document Generation

Agents draft business plans, marketing strategies, and technical specs — stored in a shared document center.

Document center with AI-generated deliverables

One-Click Company Creation

Name it, describe the mission, connect a runtime, and launch. Agents start working in under a minute.

Company creation onboarding flow


Quick Start

Download

Grab the latest release for your platform:

Download AgentCompany

Available for macOS (Apple Silicon & Intel), Windows, and Linux.

Build from Source

# Prerequisites: Node.js 22+, pnpm 10+
pnpm install
pnpm dev

Verification

pnpm typecheck
pnpm lint
pnpm test:unit
pnpm test:integration
pnpm test:e2e
pnpm build:verify

Packaging

pnpm build         # Compile + package for current platform → /build/release
pnpm build:dir     # Compile + unpackaged directory
pnpm build:current # Build for current host platform (see note below for other OS)
pnpm release:local # Signed/uploading release pipeline (see docs/release/local-r2.md)
  • Targets: macOS (.dmg), Windows (.exe / NSIS), Linux (.AppImage)
  • Packaging uses electron-builder
  • Local builds use ad-hoc signing (CSC_IDENTITY_AUTO_DISCOVERY=false)
  • Defaults to --publish never; override with AGENTCOMPANY_ELECTRON_PUBLISH
  • Cloudflare R2 release hosting + auto-update pipeline: docs/release/local-r2.md

Architecture

src/
  main/              # Electron main process — database, services, IPC, orchestration
  preload/           # Context-isolated bridge — DesktopApi via contextBridge
  renderer/          # React 19 UI — components, hooks, i18n
  shared/            # Contracts, types, Zod schemas shared across processes
packages/
  adapter-utils/     # Shared adapter utilities
  adapter-claude-local/
  adapter-codex-local/
  adapter-gemini-local/

Key Design Decisions

  • Local-first: SQLite database, secrets in OS keychain, no external services required
  • Security: contextIsolation: true, nodeIntegration: false, Zod-validated IPC, JWT agent tokens
  • Agent coordination: Agents delegate tasks, escalate blockers, and produce deliverables through the orchestration runtime

Tech Stack

Layer Technology
Framework Electron 39.8.0
Runtime Node.js 22+
Language TypeScript 5.9 (strict)
UI React 19, Tailwind CSS 4, Framer Motion
Build electron-vite, Vite 7, electron-builder
Database SQLite (WAL mode, schema in src/main/database/)
Validation Zod 4
Testing Vitest, Playwright

License

MIT


Built with quiet authority. Ship your AI company.

S
Description
No description provided
Readme MIT
135 MiB
0 Stars 1 Watchers 0 Forks
2026-10-10 01:31:40 +00:00
Languages
TypeScript 93.7%
Shell 3%
CSS 2.3%
Python 0.5%
JavaScript 0.4%