[kimi] Centralize agent token rules and hooks for automations (#711) #792
Reference in New Issue
Block a user
Delete Branch "kimi/issue-711"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #711
Summary
This PR centralizes agent token rules and hooks for automations as described in the Token Economy v1 milestone.
Changes
1. Token Rules Configuration (
timmy_automations/config/token_rules.yaml)Defines the complete token economy:
pr_merged: +10,automation_failure: -2)pr_merge: 0,sensitive_config_change: 50)triage.max_earn: 100)2. Token Rules Helper Module (
timmy_automations/utils/token_rules.py)Provides a clean API for automations:
TokenRules.get_delta(event_name)- Get token delta for an eventTokenRules.compute_transaction(...)- Full transaction with gating and limit checksTokenRules.check_gate(operation, current_tokens)- Verify agent can perform operationget_token_delta(),compute_token_reward()- Convenience functions3. Daily Run Integration (
timmy_automations/daily_run/orchestrator.py)First automation path using the token helpers:
daily_run_completedreward (+5 tokens) on successful completiongolden_path_generatedreward (+3 tokens) when agenda createdautomation_failurepenalty (-2 tokens) on errors4. Comprehensive Tests (
tests/timmy_automations/test_token_rules.py)Covers:
Acceptance Criteria
Testing