This guide will walk you through creating your first proactive agent with Macroa Pulse. You’ll learn how to detect filesystem changes and trigger agent actions without cron jobs, webhooks, or LLM polling.
The threshold parameter controls how selective the Pulse is. Lower values (e.g., 0.3) trigger more often; higher values (e.g., 0.8) are more conservative.
4
Register a module with a fingerprint
Modules describe what signals are relevant using a signal fingerprint:
registry.register_module( "document-agent", { "module_id": "document-agent", "cluster": "documents", "version": "1.0", "question_template": "A new file appeared at {location}. Is this relevant to the user's work?", "default_threshold": 0.65, "signal_priors": { "filesystem": { "watch_directories": ["~/pulse_demo"], "relevant_extensions": [".txt", ".pdf", ".docx"], "irrelevant_extensions": [".tmp", ".log"] } } })
The fingerprint provides priors that initialize the neural network on day one. The Pulse learns from feedback over time and adapts to your actual usage patterns.
5
Subscribe to escalations
When the Pulse decides something is worth attention, it calls your escalation handler:
def handle_escalation(decision: EscalationDecision): print(f"🔔 Pulse escalation:") print(f" Module: {decision.module_id}") print(f" Question: {decision.question}") print(f" Confidence: {decision.confidence:.2f}") # This is where you'd wake your agent with the scoped question # For now, we'll just print itregistry.on_escalation(handle_escalation)
The EscalationDecision contains:
module_id - Which module triggered
question - The specific question formed by Layer 3
confidence - The relevance score from Layer 2
should_escalate - Whether to wake the agent
6
Start the Pulse
Start all three layers:
registry.start()print("Pulse is running. Monitoring ~/pulse_demo for changes...")
The Pulse runs in background threads. Your main program continues executing.
7
Test the system
Keep the script running and create a new file in the monitored directory:
echo "Hello, Pulse!" > ~/pulse_demo/test.txt
Within a few seconds, you should see:
🔔 Pulse escalation: Module: document-agent Question: A new file appeared at ~/pulse_demo/test.txt. Is this relevant to the user's work? Confidence: 0.72
8
Provide feedback (optional)
After handling an escalation, provide feedback to improve the model:
def handle_escalation(decision: EscalationDecision): # ... handle the decision ... # Record activation and get an ID activation_id = registry.record_activation( decision.module_id, decision.triggering_events ) # Later, after the agent acts, provide feedback # 1.0 = useful, 0.0 = not useful registry.record_feedback(activation_id, 1.0)
Feedback enables online learning. The Pulse adapts to your usage patterns without manual retraining.
The fingerprint is used to initialize the neural network. The Pulse learns from feedback over time, so it’s okay if the priors aren’t perfect on day one.