akiiwa-games/AgentCompass / skills/agent-compass
agent-compass
FlaggedChoose owner, model and effort, outbound authorization, advisor use, and continuation for delegated work. Reads local usage and effective account policy, profiles the task with the configured System-One scorer, then allocates a compatible worker. Use for independent worker or advisor work; ordinary local execution needs no routing.
scripts/test_roll_notifications.py
View on GitHub"""Notification ownership and caller guidance, with no live workers."""
from pathlib import Path
from types import SimpleNamespace
import tempfile
import unittest
from unittest.mock import Mock, patch
import roll
import subscription_cli
import turn_refusal
import worker_sessions
from router_test_support import isolated_router_state
def setUpModule():
isolated_router_state(unittest.addModuleCleanup)
class RollNotificationTests(unittest.TestCase):
def setUp(self):
# The account side of the verdict is test_turn_refusal.py's; here the carried context alone decides.
patcher = patch.object(turn_refusal, 'worker_refusal', return_value=None)
patcher.start()
self.addCleanup(patcher.stop)
def test_continuation_uses_carried_sum_and_threshold(self):
with patch.object(worker_sessions, 'rotation_threshold', return_value=2000000):
for context, expected in ((999999, 'same worker'), (1000000, 'rotate')):
with self.subTest(context=context), patch.object(worker_sessions, 'session_state', return_value={
'compacted_tokens': 1000000, 'context_tokens': context,
'historical_context_tokens': 1, 'contextWindowUsedTokens': 99999999}):
self.assertIn(expected, worker_sessions.continuation_verdict('worker'))
with patch.object(worker_sessions, 'session_state', return_value={
'compacted_tokens': 765142, 'context_tokens': 78253}):
self.assertIn('carried 843,395', worker_sessions.continuation_verdict('worker'))
def test_unreadable_carried_context_is_unknown(self):
with patch.object(worker_sessions, 'session_state', return_value={
'telemetry_status': 'unknown', 'telemetry_reason': 'missing_log',
'contextWindowUsedTokens': 100, 'contextWindowMaxTokens': 200}):
result = worker_sessions.continuation_verdict('worker')
self.assertIn('Continuation: unknown (missing_log)', result)
self.assertNotIn('Continuation: same worker', result)
self.assertNotIn('Continuation: rotate', result)
def test_compact_includes_worker_verdict(self):
result = {'worker': {'agent_id': 'worker'}, 'continuation': 'Continuation: unknown (missing_log)'}
self.assertEqual(roll.compact(result, 'launched', None)['continuation'], result['continuation'])
def test_paseo_only_promises_registered_notifications(self):
args = SimpleNamespace(title='test', workspace=None, wait=0)
decision = {'decision_id': 'decision', 'selected_bundle': {'provider': 'codex'}}
for status, expected in (
('watching', 'will be sent'), ('delivered', 'has been delivered'),
('stopped', 'must collect'), ('delivery_failed', 'must collect'),
(None, 'must collect'),
):
with self.subTest(status=status):
receipt = {'state': 'started', 'agent_id': 'observed-worker', 'observed_at': '2026-11-01T00:00:00Z'}
if status:
receipt['completion_notification'] = {'status': status}
with patch.object(roll.dispatch_flow, 'reconcile'), \
patch.object(roll.registry, 'prepare', return_value={'dispatch_id': 'dispatch'}), \
patch.object(roll.dispatch_flow, 'launch', return_value=receipt):
result, code = roll.paseo(args, {}, decision, {}, 'fixture', 'parent', {})
self.assertEqual(code, 0)
self.assertIn(expected, result['next'])
self.assertEqual(result['worker'].get('completion_notification'), receipt.get('completion_notification'))
def test_watched_launched_next_action_forbids_shell_polling_and_tells_parent_to_end_turn(self):
watching_result = {
'dispatch_mode': 'paseo',
'worker': {'agent_id': 'worker', 'completion_notification': {'status': 'watching'}},
}
watching_compact = roll.compact(watching_result, 'launched', None)
self.assertIn('end your turn', watching_compact['next_action'])
self.assertIn('do not sleep or poll', watching_compact['next_action'])
delivered_result = {
'dispatch_mode': 'paseo',
'worker': {'agent_id': 'worker', 'completion_notification': {'status': 'delivered'}},
}
delivered_compact = roll.compact(delivered_result, 'launched', None)
self.assertIn('has been delivered', delivered_compact['next_action'])
self.assertIn('read that notification instead of waiting or polling', delivered_compact['next_action'])
self.assertNotIn('end your turn', delivered_compact['next_action'])
def test_fallback_result_relaunched_covers_watching_delivered_and_unconfirmed(self):
decision = {'decision_id': 'decision', 'selected_bundle': {'provider': 'codex'}}
bundle = {'provider': 'claude', 'account': 'claude-a', 'model': 'claude-opus-4-6', 'effort': 'medium'}
for status, expected in (
('watching', 'end your turn to wait for it'),
('delivered', 'has been delivered'),
('stopped', 'No completion notification is confirmed'),
(None, 'No completion notification is confirmed'),
):
with self.subTest(status=status):
receipt = {'dispatch_id': 'd2', 'state': 'started', 'agent_id': 'w2',
'observed_at': '2026-11-01T00:00:00Z'}
if status is not None:
receipt['completion_notification'] = {'status': status}
outcome = {'action': 'relaunched', 'dispatch_id': 'd2', 'lines': ['attempt 1'], 'receipt': receipt}
with patch.object(roll.registry, 'inspect', return_value={**receipt, 'bundle': bundle}), \
patch.object(roll.dispatch_flow, 'public_chain', return_value=dict(receipt)):
result, code = roll.fallback_result({}, outcome, decision, 'parent', SimpleNamespace())
self.assertEqual(code, 0)
self.assertIn(expected, result['next'])
if status == 'delivered':
self.assertIn('read that notification instead of waiting or polling', result['next'])
self.assertNotIn('end your turn', result['next'])
def test_unwatched_compact_launched_branches_do_not_tell_parent_to_end_turn(self):
cases = (
('paseo-stopped', {'dispatch_mode': 'paseo', 'worker': {'agent_id': 'w1',
'completion_notification': {'status': 'stopped'},
'continuation_argv': ['agentcompass', 'launch', '--dispatch-id', 'd1']}}),
('paseo-delivery-failed', {'dispatch_mode': 'paseo', 'worker': {'agent_id': 'w1',
'completion_notification': {'status': 'delivery_failed'},
'continuation_argv': ['agentcompass', 'launch', '--dispatch-id', 'd1']}}),
('paseo-none', {'dispatch_mode': 'paseo', 'worker': {'agent_id': 'w1',
'continuation_argv': ['agentcompass', 'launch', '--dispatch-id', 'd1']}}),
('dot', {'dispatch_mode': 'dot', 'continuation_argv': ['agentcompass', 'dot', 'status', 'job-1'],
'worker': {}}),
('grok-bot', {'dispatch_mode': 'grok-bot',
'continuation_argv': ['agentcompass', 'grok-bot', 'status', 'job-1'], 'worker': {}}),
('herdr', {'dispatch_mode': 'herdr',
'next': 'Herdr started child c1; run next_argv to read its output.',
'next_argv': ['agentcompass', 'herdr', 'status', 'c1'], 'worker': {}}),
)
for label, result in cases:
with self.subTest(label=label):
compact = roll.compact(result, 'launched', None)
self.assertNotIn('end your turn', compact['next_action'])
self.assertNotIn('arrives as a notification', compact['next_action'])
self.assertNotIn('wait for it', compact['next_action'])
def test_claim_or_notifier_without_observed_worker_is_pending_with_public_continuation(self):
args=SimpleNamespace(title='test',workspace=None,wait=0)
decision={'decision_id':'decision','selected_bundle':{'provider':'codex'}}
for state in ('launching','expired'):
receipt={'state':state,'launched_at':'2026-11-01T00:00:00Z',
'completion_notification':{'status':'watching'}}
with patch.object(roll.dispatch_flow,'reconcile'), \
patch.object(roll.registry,'prepare',return_value={'dispatch_id':'same-dispatch'}), \
patch.object(roll.dispatch_flow,'launch',return_value=receipt):
result,code=roll.paseo(args,{},decision,{},'fixture','parent',{})
self.assertIsNone(result['launched'])
self.assertEqual(code,0)
status=roll.status_of(result,code)
self.assertEqual(status,'pending')
compact=roll.compact(result,status,'receipt.json')
self.assertEqual(compact['next_argv'][-6:],['--dispatch-id','same-dispatch','--parent-id','parent','--watch-seconds','120'])
self.assertNotIn('scripts',' '.join(compact['next_argv']))
self.assertNotIn('Worker launched',compact['next_action'])
def test_cli_background_reply_explicitly_belongs_to_caller(self):
with tempfile.TemporaryDirectory() as folder:
process = Mock(pid=1234)
args = SimpleNamespace(wait=0)
with patch.object(subscription_cli, 'subscription_env', return_value={}), patch.object(roll, 'CLI_RUNS_DIR', Path(folder)), \
patch.object(roll, 'provider_definition', return_value=('codex', {})), \
patch.object(roll, 'cli_command', return_value=['fake-codex']), \
patch.object(roll.subprocess, 'Popen', return_value=process):
result, code = roll.cli(args, {'parent_id': 'parent', 'parent_host': 'native',
'parent_address': 'inbox'}, {'provider': 'codex', 'model': 'fixture'}, 'fixture')
self.assertEqual(code, 0)
self.assertIn('No automatic completion notification', result['next'])
self.assertIn('must watch worker.output and worker.stderr', result['next'])
self.assertIn('1234', result['next'])
if __name__ == '__main__':
unittest.main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |