Auth & Telemetry
Relevant source files
The following files were used as context for generating this wiki page:
The Auth & Telemetry systems in the Autohand CLI provide the infrastructure for user identity management, session tracking, and quality improvement through feedback loops. These systems ensure that the agent can authenticate with the Autohand API, track usage metrics across local and cloud environments, and collect user insights to refine the agent's performance.
The architecture is designed to be privacy-conscious, with telemetry disabled by default and explicit opt-in mechanisms for cloud synchronization. It integrates deeply with the session management logic to provide a persistent "memory" of project-specific successes and failures.
Sources: src/core/agent.ts:186-210, README.md:162-168
Telemetry System Architecture
The TelemetryManager acts as the central hub for capturing events during the agent's lifecycle. It tracks everything from session starts and model switches to specific tool executions and errors.
Component Interaction
The diagram shows how the AutohandAgent interacts with the TelemetryManager to log activities both locally and to the cloud API.
Sources: src/core/agent.ts:186-210, src/core/agent.ts:1095-1110
Key Telemetry Events
| Event Type | Description | Data Captured |
|---|---|---|
| Session Start | Initiated when the agent starts or resumes a session. | Session ID, Model ID, Provider. |
| Tool Use | Recorded every time a tool (e.g., write_file) is called. | Tool name, success status, duration, error (if any). |
| Model Switch | Captured when the user changes the LLM provider or model. | Previous model, new model, provider. |
| Interaction | General interaction counter for feedback triggering. | interaction count per session. |
| Session Sync | Uploads session history to the cloud for persistence. | Message history, workspace metadata. |
Sources: src/core/agent.ts:192-205, src/core/agent.ts:250-300, src/core/agent.ts:1100-1120
User Feedback & Interaction
The FeedbackManager is responsible for soliciting user sentiment at critical junctures, such as after successful task completion or session exit. It uses a triggering system to avoid over-prompting the user.
Feedback Workflow
The sequence diagram illustrates the logic for determining when to ask the user for feedback during a session termination.
Sources: src/core/agent.ts:1095-1115, src/feedback/FeedbackManager.ts (referenced via agent.ts)
Authentication & API Integration
Authentication is handled primarily through the /login command, which interfaces with the Autohand API to store credentials in the local configuration.
Auth Data Flow
- User Login: The user executes
/login, providing credentials or an API key. - Configuration Persistence: The
AuthClient(managed viaagent.ts) saves the user's information to theconfig.jsonfile. - Context Injection: When a session starts, the agent's system prompt is updated with the current user's name or email to personalize the interaction.
Sources: src/core/agent.ts:140-155, src/core/agent.ts:1174-1180
Technical Implementation in AutohandAgent
The agent initializes these managers in its constructor, sourcing the API base URL from the configuration:
this.feedbackManager = new FeedbackManager({
apiBaseUrl: runtime.config.api?.baseUrl || 'https://api.autohand.ai',
cliVersion: packageJson.version
});
this.telemetryManager = new TelemetryManager({
enabled: runtime.config.telemetry?.enabled === true,
apiBaseUrl: runtime.config.telemetry?.apiBaseUrl || 'https://api.autohand.ai',
enableSessionSync: runtime.config.telemetry?.enableSessionSync === true
});
Sources: src/core/agent.ts:193-205
Historical Retrieval & Project Knowledge
Telemetry data is repurposed locally by the ProjectManager to build "Project Knowledge." This system learns from past successes and failures recorded in telemetry logs to prevent the agent from repeating mistakes.
Project Learning Schema
- Failures (
failures.jsonl): Records tool calls that resulted in errors. - Successes (
successes.jsonl): Records patterns that led to successful outcomes (e.g., build passing). - Knowledge (
knowledge.json): A synthesized summary of anti-patterns and best practices for a specific project.
Sources: prd/historical-retrieval.md:120-165, src/session/ProjectManager.ts:100-150
Anti-Pattern Detection Flow
Summary
The Auth & Telemetry systems provide a robust framework for both user management and autonomous learning. By tracking session data and model performance, Autohand can synchronize progress to the cloud while simultaneously building a local knowledge base that improves agent reliability over time. The feedback system ensures that development remains user-centric, while the modular design allows for granular control over what data is shared with the Autohand API.