loki-mode 11.36.0 → 11.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/dashboard/__init__.py +1 -1
  4. package/docs/CLI-REFERENCE.md +1 -1
  5. package/docs/COMPONENTS.md +2 -2
  6. package/docs/INSTALLATION.md +1 -1
  7. package/docs/ISSUE-TO-PR-GOLDEN-PATH-PLAN.md +2 -2
  8. package/docs/dev/project-structure.md +0 -1
  9. package/loki-ts/dist/loki.js +2 -2
  10. package/mcp/__init__.py +1 -1
  11. package/package.json +2 -2
  12. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  13. package/references/agent-types.md +1047 -0
  14. package/skills/agents.md +1 -1
  15. package/skills/production.md +602 -1
  16. package/skills/providers.md +256 -1
  17. package/web-app/dist/assets/{AdminPage-D73t1zi7.js → AdminPage-VMdXCL6Z.js} +1 -1
  18. package/web-app/dist/assets/{Avatar-Pgu94LDs.js → Avatar-u2uOGouZ.js} +1 -1
  19. package/web-app/dist/assets/{Badge-B2X33p01.js → Badge-Djyiy-OK.js} +1 -1
  20. package/web-app/dist/assets/{Button-BaRCk5ob.js → Button-DtzBRjJb.js} +1 -1
  21. package/web-app/dist/assets/{CockpitPage-Du1NIwsO.js → CockpitPage-B5Q3cIfS.js} +1 -1
  22. package/web-app/dist/assets/{ComparePage-CVLjwYcX.js → ComparePage-D26OOxGe.js} +1 -1
  23. package/web-app/dist/assets/{ErrorBoundary-C6umXLhq.js → ErrorBoundary-gQ0ajPif.js} +1 -1
  24. package/web-app/dist/assets/{EvidenceReceiptPanel-BVOwvWB9.js → EvidenceReceiptPanel-BoWDPbo6.js} +1 -1
  25. package/web-app/dist/assets/{GitHubIssuesPanel-CgKnhO5u.js → GitHubIssuesPanel-C4gdFuJu.js} +1 -1
  26. package/web-app/dist/assets/{GitHubPRsPanel-PRvPjrr2.js → GitHubPRsPanel-Gb37Pfw2.js} +1 -1
  27. package/web-app/dist/assets/{HomePage-DcZri4TP.js → HomePage-C2XTx12e.js} +2 -2
  28. package/web-app/dist/assets/{LoginPage-_4Ao0Rez.js → LoginPage-Bpmi4ohR.js} +1 -1
  29. package/web-app/dist/assets/{MagicPage-BbJc2ZOg.js → MagicPage-B5nvAWDT.js} +1 -1
  30. package/web-app/dist/assets/{MetricsPage-CeZVEo69.js → MetricsPage-TcUUhxGR.js} +1 -1
  31. package/web-app/dist/assets/{NotFoundPage-g8x8mIY4.js → NotFoundPage-feaH_MlW.js} +1 -1
  32. package/web-app/dist/assets/{ProjectPage-DJa1I91a.js → ProjectPage-DctsQGNj.js} +3 -3
  33. package/web-app/dist/assets/{ProjectsPage-DNLPtJay.js → ProjectsPage-DQQ-t6go.js} +1 -1
  34. package/web-app/dist/assets/{SettingsPage-BlpOmTtJ.js → SettingsPage-BSgKRreC.js} +1 -1
  35. package/web-app/dist/assets/{ShowcasePage-CHJyHYEN.js → ShowcasePage-DfPu21Jh.js} +1 -1
  36. package/web-app/dist/assets/{SystemSettingsPage-0ZnQejCy.js → SystemSettingsPage-h9_O9kOO.js} +1 -1
  37. package/web-app/dist/assets/{TeamsPage-FdJfcD1C.js → TeamsPage-C7DTUuMO.js} +1 -1
  38. package/web-app/dist/assets/{TemplatesPage-CaPsg6RE.js → TemplatesPage-Bi37a0cj.js} +1 -1
  39. package/web-app/dist/assets/{TerminalOutput-BBf53veh.js → TerminalOutput-DQzYlXby.js} +1 -1
  40. package/web-app/dist/assets/{activity-BZZBaTk4.js → activity-DLAeEmKf.js} +1 -1
  41. package/web-app/dist/assets/{bell-CEbh5wcI.js → bell-DgRtSLvd.js} +1 -1
  42. package/web-app/dist/assets/{bot-CR3ELz3P.js → bot-C2m7OeqV.js} +1 -1
  43. package/web-app/dist/assets/{check-CSZ8Imm9.js → check-BrBcDclF.js} +1 -1
  44. package/web-app/dist/assets/{chevron-left-DanE2Hss.js → chevron-left-C9VzYegT.js} +1 -1
  45. package/web-app/dist/assets/{circle-alert-DbJb8YuD.js → circle-alert-BCmS5TEl.js} +1 -1
  46. package/web-app/dist/assets/{clock-BP8uTe0w.js → clock-BNvzvy9h.js} +1 -1
  47. package/web-app/dist/assets/{cloud-L-gsOd6z.js → cloud-B9RC-OzI.js} +1 -1
  48. package/web-app/dist/assets/{code-xml-Y_EN8uAF.js → code-xml-Dq5h9Y4x.js} +1 -1
  49. package/web-app/dist/assets/{database-Dk3IyOhB.js → database-BZM5e6dN.js} +1 -1
  50. package/web-app/dist/assets/{dollar-sign-u1BAuVVd.js → dollar-sign-CG2hFMYV.js} +1 -1
  51. package/web-app/dist/assets/{file-code-corner-Cx4c5ngU.js → file-code-corner-CbkPzEr1.js} +1 -1
  52. package/web-app/dist/assets/{file-plus-ZttsmeuR.js → file-plus-DLIPXn2k.js} +1 -1
  53. package/web-app/dist/assets/{globe-B4wt_UbY.js → globe-7kPrJ_Vy.js} +1 -1
  54. package/web-app/dist/assets/{hammer-Bkkzme0X.js → hammer-ZsTmZCz4.js} +1 -1
  55. package/web-app/dist/assets/{index-qFl2U4PP.js → index-BJfP9ylx.js} +3 -3
  56. package/web-app/dist/assets/{layers-uK6Y9vzW.js → layers-DT-7ulEf.js} +1 -1
  57. package/web-app/dist/assets/{loader-circle-CSEhSCyJ.js → loader-circle-B4HgIJl7.js} +1 -1
  58. package/web-app/dist/assets/{lock-Cl8vENNw.js → lock-CcK3qv3U.js} +1 -1
  59. package/web-app/dist/assets/{package-B4KdlkGK.js → package-D7j5jIRE.js} +1 -1
  60. package/web-app/dist/assets/{plus-Cx7wCatc.js → plus-D61O8i_1.js} +1 -1
  61. package/web-app/dist/assets/{refresh-cw-Ba8y00l0.js → refresh-cw-BwKxbGei.js} +1 -1
  62. package/web-app/dist/assets/{rotate-ccw-Dj_tGfar.js → rotate-ccw-BFsHb_Do.js} +1 -1
  63. package/web-app/dist/assets/{scroll-text-DKp4aaqK.js → scroll-text-BHIKikTn.js} +1 -1
  64. package/web-app/dist/assets/{server-DHSSF41S.js → server-DbucCXky.js} +1 -1
  65. package/web-app/dist/assets/{shield-alert-3z9YnSzz.js → shield-alert-CfPhky3w.js} +1 -1
  66. package/web-app/dist/assets/{thumbs-up-BA2y9kYN.js → thumbs-up-CyQoJXN3.js} +1 -1
  67. package/web-app/dist/assets/{trash-2-0RcWshkw.js → trash-2-DTmFWzg7.js} +1 -1
  68. package/web-app/dist/assets/{trending-down-BdhmG8vV.js → trending-down-CS5Oqc6g.js} +1 -1
  69. package/web-app/dist/assets/{trending-up-Cn6kNnmP.js → trending-up-CmBBN4R9.js} +1 -1
  70. package/web-app/dist/assets/{upload-DFOQfmyN.js → upload-DGePZkS3.js} +1 -1
  71. package/web-app/dist/assets/{usePolling-40ulE-Te.js → usePolling-DEPQP4xT.js} +1 -1
  72. package/web-app/dist/assets/{user-BVPC2VOO.js → user-Bogh2WEE.js} +1 -1
  73. package/web-app/dist/index.html +1 -1
  74. package/references/agents.md +0 -1043
  75. package/references/multi-provider.md +0 -445
  76. package/references/production-patterns.md +0 -574
package/skills/agents.md CHANGED
@@ -276,4 +276,4 @@ See `references/agent-types.md` for complete specifications. Summary:
276
276
 
277
277
  **Spawn only what you need.** Simple project: 5-10 agents. Complex startup: more as needed.
278
278
 
279
- References: `references/agents.md` (full role prompts for the 41 agents), `references/business-ops.md` (business-domain agent workflows), `references/tool-orchestration.md` (tracing spans, efficiency metrics, reward signals, dynamic agent selection).
279
+ References: `references/agent-types.md` (role specs, per-role task types and quality checks, communication protocol), `references/business-ops.md` (business-domain agent workflows), `references/tool-orchestration.md` (tracing spans, efficiency metrics, reward signals, dynamic agent selection).
@@ -17,11 +17,44 @@
17
17
  - [Batch API Limits](#batch-api-limits)
18
18
  - [Implementation Pattern](#implementation-pattern)
19
19
  - [Batch + Prompt Caching](#batch--prompt-caching)
20
+ - [Install Packages Locally](#install-packages-locally)
21
+ - [What Actually Works in Production](#what-actually-works-in-production)
22
+ - [Human-in-the-Loop (HITL) is Non-Negotiable](#human-in-the-loop-hitl-is-non-negotiable)
23
+ - [Narrow Scope Wins](#narrow-scope-wins)
24
+ - [Confidence-Based Routing](#confidence-based-routing)
25
+ - [Classification Before Automation](#classification-before-automation)
26
+ - [Deterministic Outer Loops](#deterministic-outer-loops)
27
+ - [Context Engineering Patterns](#context-engineering-patterns)
28
+ - [Context Curation Over Automatic Selection](#context-curation-over-automatic-selection)
29
+ - [Information Abstraction](#information-abstraction)
30
+ - [Separate Conversations Per Task](#separate-conversations-per-task)
31
+ - [Skills System Pattern](#skills-system-pattern)
32
+ - [On-Demand Skill Loading](#on-demand-skill-loading)
33
+ - [Sub-Agents for Context Isolation](#sub-agents-for-context-isolation-1)
34
+ - [Planning Before Execution](#planning-before-execution)
35
+ - [Explicit Plan-Then-Code Workflow](#explicit-plan-then-code-workflow)
36
+ - [Multi-Agent Orchestration Patterns](#multi-agent-orchestration-patterns)
37
+ - [Event-Driven Coordination](#event-driven-coordination)
38
+ - [Policy-First Enforcement](#policy-first-enforcement)
39
+ - [Simulation Layer](#simulation-layer)
40
+ - [Evaluation and Benchmarking](#evaluation-and-benchmarking)
41
+ - [Problems with Current Benchmarks](#problems-with-current-benchmarks)
42
+ - [Practical Evaluation Approach](#practical-evaluation-approach)
43
+ - [Cost and Token Economics](#cost-and-token-economics)
44
+ - [Real-World Cost Patterns](#real-world-cost-patterns)
45
+ - [Cross-Process File Lock (v7.5.5)](#cross-process-file-lock-v755)
46
+ - [Sources](#sources)
20
47
  <!-- TOC:END -->
21
48
 
22
49
  ## HN 2025 Production Patterns
23
50
 
24
- Narrow scope, deterministic outer loops and context engineering live in `references/production-patterns.md` (single source). The sections below cover deployment-side patterns.
51
+ Practitioner-tested patterns from Hacker News discussions and real-world deployments. These patterns represent what actually works in production, not theoretical frameworks. The deployment-side patterns come first; the practitioner patterns follow them.
52
+
53
+ This module consolidates battle-tested insights from:
54
+ - HN discussions on autonomous agents in production (2025)
55
+ - Coding with LLMs practitioner experiences
56
+ - Simon Willison's Superpowers coding agent patterns
57
+ - Multi-agent orchestration real-world deployments
25
58
 
26
59
  ---
27
60
 
@@ -274,4 +307,572 @@ requests = [
274
307
  - Cache hit: 90% reduction on cached tokens
275
308
  - Combined: Up to 95% savings on large batches
276
309
 
310
+
311
+ ## Install Packages Locally
312
+
313
+ Install dependencies into the project (a local `node_modules`, virtualenv or vendor directory) rather than globally, so a run is reproducible, never alters the host, and is removed with the workspace.
314
+
315
+ ---
316
+
317
+ ## What Actually Works in Production
318
+
319
+ ### Human-in-the-Loop (HITL) is Non-Negotiable
320
+
321
+ **Key Insight:** "Zero companies don't have a human in the loop" for customer-facing applications.
322
+
323
+ ```yaml
324
+ hitl_patterns:
325
+ always_human:
326
+ - Customer-facing responses
327
+ - Financial transactions
328
+ - Security-critical operations
329
+ - Legal/compliance decisions
330
+
331
+ automation_candidates:
332
+ - Internal tooling
333
+ - Developer assistance
334
+ - Data preprocessing
335
+ - Code generation (with review)
336
+
337
+ implementation:
338
+ - Classification layer routes to human vs automated
339
+ - Confidence thresholds trigger escalation
340
+ - Audit trails for all automated decisions
341
+ ```
342
+
343
+ ### Narrow Scope Wins
344
+
345
+ **Key Insight:** Successful agents operate within tightly constrained domains.
346
+
347
+ ```yaml
348
+ scope_constraints:
349
+ max_steps_before_review: 3-5
350
+ task_characteristics:
351
+ - Specific, well-defined objectives
352
+ - Pre-classified inputs
353
+ - Deterministic success criteria
354
+ - Verifiable outputs
355
+
356
+ successful_domains:
357
+ - Email scanning and classification
358
+ - Invoice processing
359
+ - Code refactoring (bounded)
360
+ - Documentation generation
361
+ - Test writing
362
+
363
+ failure_prone_domains:
364
+ - Open-ended feature implementation
365
+ - Novel algorithm design
366
+ - Security-critical code
367
+ - Cross-system integrations
368
+ ```
369
+
370
+ ### Confidence-Based Routing
371
+
372
+ **Key Insight:** Treat agents as preprocessors, not decision-makers.
373
+
374
+ ```python
375
+ def confidence_based_routing(agent_output):
376
+ """
377
+ Route based on confidence, not capability.
378
+ Based on production practitioner patterns.
379
+ """
380
+ confidence = agent_output.confidence_score
381
+
382
+ if confidence >= 0.95:
383
+ # High confidence: auto-approve with logging
384
+ return AutoApprove(audit_log=True)
385
+
386
+ elif confidence >= 0.70:
387
+ # Medium confidence: quick human review
388
+ return HumanReview(priority="normal", timeout="1h")
389
+
390
+ elif confidence >= 0.40:
391
+ # Low confidence: detailed human review
392
+ return HumanReview(priority="high", context="full")
393
+
394
+ else:
395
+ # Very low confidence: escalate immediately
396
+ return Escalate(reason="low_confidence", require_senior=True)
397
+ ```
398
+
399
+ ### Classification Before Automation
400
+
401
+ **Key Insight:** Separate inputs before processing.
402
+
403
+ ```yaml
404
+ classification_first:
405
+ step_1_classify:
406
+ workable:
407
+ - Clear requirements
408
+ - Existing patterns
409
+ - Test coverage available
410
+ non_workable:
411
+ - Ambiguous requirements
412
+ - Novel architecture
413
+ - Missing dependencies
414
+ escalate_immediately:
415
+ - Security concerns
416
+ - Compliance requirements
417
+ - Customer-facing changes
418
+
419
+ step_2_route:
420
+ workable: "Automated pipeline"
421
+ non_workable: "Human clarification"
422
+ escalate: "Senior review"
423
+ ```
424
+
425
+ ### Deterministic Outer Loops
426
+
427
+ **Key Insight:** Wrap agent outputs with rule-based validation.
428
+
429
+ ```python
430
+ def deterministic_validation_loop(task, max_attempts=3):
431
+ """
432
+ Use LLMs only where genuine ambiguity exists.
433
+ Wrap with deterministic rules.
434
+ """
435
+ for attempt in range(max_attempts):
436
+ # LLM handles the ambiguous part
437
+ output = agent.execute(task)
438
+
439
+ # Deterministic validation (NOT LLM)
440
+ validation_errors = []
441
+
442
+ # Rule: Must have tests
443
+ if not output.has_tests:
444
+ validation_errors.append("Missing tests")
445
+
446
+ # Rule: Must pass linting
447
+ lint_result = run_linter(output.code)
448
+ if lint_result.errors:
449
+ validation_errors.append(f"Lint errors: {lint_result.errors}")
450
+
451
+ # Rule: Must compile
452
+ compile_result = compile_code(output.code)
453
+ if not compile_result.success:
454
+ validation_errors.append(f"Compile error: {compile_result.error}")
455
+
456
+ # Rule: Tests must pass
457
+ if output.has_tests:
458
+ test_result = run_tests(output.code)
459
+ if not test_result.all_passed:
460
+ validation_errors.append(f"Test failures: {test_result.failures}")
461
+
462
+ if not validation_errors:
463
+ return output
464
+
465
+ # Feed errors back for retry
466
+ task = task.with_feedback(validation_errors)
467
+
468
+ return FailedResult(reason="Max attempts exceeded")
469
+ ```
470
+
471
+ ---
472
+
473
+ ## Context Engineering Patterns
474
+
475
+ ### Context Curation Over Automatic Selection
476
+
477
+ **Key Insight:** Manually choose which files and information to provide.
478
+
479
+ ```yaml
480
+ context_curation:
481
+ principles:
482
+ - "Less is more" - focused context beats comprehensive context
483
+ - Manual selection outperforms automatic RAG
484
+ - Remove outdated information aggressively
485
+
486
+ anti_patterns:
487
+ - Dumping entire codebase into context
488
+ - Relying on automatic context selection
489
+ - Accumulating conversation history indefinitely
490
+
491
+ implementation:
492
+ per_task_context:
493
+ - 2-5 most relevant files
494
+ - Specific functions, not entire modules
495
+ - Recent changes only (last 1-2 days)
496
+ - Clear success criteria
497
+
498
+ context_budget:
499
+ target: "< 10k tokens for context"
500
+ reserve: "90% for model reasoning"
501
+ ```
502
+
503
+ ### Information Abstraction
504
+
505
+ **Key Insight:** Summarize rather than feeding full data.
506
+
507
+ ```python
508
+ def abstract_for_agent(raw_data, task_context):
509
+ """
510
+ Design abstractions that preserve decision-relevant information.
511
+ Based on practitioner insights.
512
+ """
513
+ # BAD: Feed 10,000 database rows
514
+ # raw_data = db.query("SELECT * FROM users")
515
+
516
+ # GOOD: Summarize to decision-relevant info
517
+ summary = {
518
+ "query_status": "success",
519
+ "total_results": len(raw_data),
520
+ "sample": raw_data[:5],
521
+ "schema": extract_schema(raw_data),
522
+ "statistics": {
523
+ "null_count": count_nulls(raw_data),
524
+ "unique_values": count_uniques(raw_data),
525
+ "date_range": get_date_range(raw_data)
526
+ }
527
+ }
528
+
529
+ return summary
530
+ ```
531
+
532
+ ### Separate Conversations Per Task
533
+
534
+ **Key Insight:** Fresh contexts yield better results than accumulated sessions.
535
+
536
+ ```yaml
537
+ conversation_management:
538
+ new_conversation_triggers:
539
+ - Different domain (backend -> frontend)
540
+ - New feature vs bug fix
541
+ - After completing major task
542
+ - When errors accumulate (3+ in row)
543
+
544
+ preserve_across_sessions:
545
+ - CLAUDE.md / CONTINUITY.md
546
+ - Architectural decisions
547
+ - Key constraints
548
+
549
+ discard_between_sessions:
550
+ - Debugging attempts
551
+ - Abandoned approaches
552
+ - Intermediate drafts
553
+ ```
554
+
555
+ ---
556
+
557
+ ## Skills System Pattern
558
+
559
+ ### On-Demand Skill Loading
560
+
561
+ **Key Insight:** Skills remain dormant until the model actively seeks them out.
562
+
563
+ ```yaml
564
+ skills_architecture:
565
+ core_interaction: "< 2k tokens"
566
+ skill_loading: "On-demand via search"
567
+
568
+ implementation:
569
+ skill_discovery:
570
+ - Shell script searches skill files
571
+ - Model requests specific skills by name
572
+ - Skills loaded only when needed
573
+
574
+ skill_structure:
575
+ name: "unique-skill-name"
576
+ trigger: "Pattern that activates skill"
577
+ content: "Detailed instructions"
578
+ dependencies: ["other-skills"]
579
+
580
+ benefits:
581
+ - Minimal base context
582
+ - Extensible without bloat
583
+ - Skills can be updated independently
584
+ ```
585
+
586
+ ### Sub-Agents for Context Isolation
587
+
588
+ **Key Insight:** Prevent massive token waste by isolating context-noisy subtasks.
589
+
590
+ ```python
591
+ async def context_isolated_search(query, codebase_path):
592
+ """
593
+ Use sub-agent for grep/search to prevent context pollution.
594
+ Based on Simon Willison's patterns.
595
+ """
596
+ # Main agent stays focused
597
+ # Sub-agent handles noisy file searching
598
+
599
+ search_agent = spawn_subagent(
600
+ role="codebase-searcher",
601
+ context_limit="10k tokens",
602
+ permissions=["read-only"]
603
+ )
604
+
605
+ results = await search_agent.execute(
606
+ task=f"Find files related to: {query}",
607
+ codebase=codebase_path
608
+ )
609
+
610
+ # Return only relevant paths, not full content
611
+ return FilteredResults(
612
+ paths=results.relevant_files[:10],
613
+ summaries=results.file_summaries,
614
+ confidence=results.relevance_scores
615
+ )
616
+ ```
617
+
618
+ ---
619
+
620
+ ## Planning Before Execution
621
+
622
+ ### Explicit Plan-Then-Code Workflow
623
+
624
+ **Key Insight:** Have models articulate detailed plans without immediately writing code.
625
+
626
+ ```yaml
627
+ plan_then_code:
628
+ phase_1_planning:
629
+ outputs:
630
+ - spec.md: "Detailed requirements"
631
+ - todo.md: "Tagged tasks [BUG], [FEAT], [REFACTOR]"
632
+ - approach.md: "Implementation strategy"
633
+ constraints:
634
+ - NO CODE in this phase
635
+ - Human review before proceeding
636
+ - Clear success criteria
637
+
638
+ phase_2_review:
639
+ checks:
640
+ - Plan addresses all requirements
641
+ - Approach is feasible
642
+ - No missing dependencies
643
+ - Tests are specified
644
+
645
+ phase_3_implementation:
646
+ constraints:
647
+ - Follow plan exactly
648
+ - One task at a time
649
+ - Test after each change
650
+ - Report deviations immediately
651
+ ```
652
+
653
+ ---
654
+
655
+ ## Multi-Agent Orchestration Patterns
656
+
657
+ ### Event-Driven Coordination
658
+
659
+ **Key Insight:** Move beyond synchronous prompt chaining to asynchronous, decoupled systems.
660
+
661
+ ```yaml
662
+ event_driven_orchestration:
663
+ problems_with_synchronous:
664
+ - Doesn't scale
665
+ - Mixes orchestration with prompt logic
666
+ - Single failure breaks entire chain
667
+ - No retry/recovery mechanism
668
+
669
+ async_architecture:
670
+ message_queue:
671
+ - Agents communicate via events
672
+ - Decoupled execution
673
+ - Natural retry/dead-letter handling
674
+
675
+ state_management:
676
+ - Persistent task state
677
+ - Checkpoint/resume capability
678
+ - Clear ownership of data
679
+
680
+ error_handling:
681
+ - Per-agent retry policies
682
+ - Circuit breakers
683
+ - Graceful degradation
684
+ ```
685
+
686
+ ### Policy-First Enforcement
687
+
688
+ **Key Insight:** Govern agent behavior at runtime, not just training time.
689
+
690
+ ```python
691
+ class PolicyEngine:
692
+ """
693
+ Runtime governance for agent behavior.
694
+ Based on autonomous control plane patterns.
695
+ """
696
+
697
+ def __init__(self, policies):
698
+ self.policies = policies
699
+
700
+ async def enforce(self, agent_action, context):
701
+ for policy in self.policies:
702
+ result = await policy.evaluate(agent_action, context)
703
+
704
+ if result.blocked:
705
+ return BlockedAction(
706
+ reason=result.reason,
707
+ policy=policy.name,
708
+ remediation=result.suggested_action
709
+ )
710
+
711
+ if result.modified:
712
+ agent_action = result.modified_action
713
+
714
+ return AllowedAction(agent_action)
715
+
716
+ # Example policies
717
+ policies = [
718
+ NoProductionDataDeletion(),
719
+ NoSecretsInCode(),
720
+ MaxTokenBudget(limit=100000),
721
+ RequireTestsForCode(),
722
+ BlockExternalNetworkCalls(in_sandbox=True)
723
+ ]
724
+ ```
725
+
726
+ ### Simulation Layer
727
+
728
+ **Key Insight:** Evaluate changes before deploying to real environment.
729
+
730
+ ```yaml
731
+ simulation_layer:
732
+ purpose: "Test agent behavior in safe environment"
733
+
734
+ implementation:
735
+ sandbox_environment:
736
+ - Isolated container
737
+ - Mocked external services
738
+ - Synthetic data
739
+ - Full audit logging
740
+
741
+ validation_checks:
742
+ - Run tests in sandbox first
743
+ - Compare outputs to expected
744
+ - Check for policy violations
745
+ - Measure resource consumption
746
+
747
+ promotion_criteria:
748
+ - All tests pass
749
+ - No policy violations
750
+ - Resource usage within limits
751
+ - Human approval (for sensitive changes)
752
+ ```
753
+
754
+ ---
755
+
756
+ ## Evaluation and Benchmarking
757
+
758
+ ### Problems with Current Benchmarks
759
+
760
+ **Key Insight:** LLM-as-judge creates shared blind spots.
761
+
762
+ ```yaml
763
+ benchmark_problems:
764
+ llm_judge_issues:
765
+ - Same architecture = same failure modes
766
+ - Math errors accepted as correct
767
+ - "Do-nothing" baseline passes 38% of time
768
+
769
+ contamination:
770
+ - Published benchmarks become training targets
771
+ - Overfitting to specific datasets
772
+ - Inflated scores don't reflect real performance
773
+
774
+ solutions:
775
+ held_back_sets: "90% public, 10% private"
776
+ human_evaluation: "Final published results require humans"
777
+ production_testing: "A/B tests measure actual value"
778
+ objective_outcomes: "Simulated environments with verifiable results"
779
+ ```
780
+
781
+ ### Practical Evaluation Approach
782
+
783
+ ```python
784
+ def evaluate_agent_change(before_agent, after_agent, task_set):
785
+ """
786
+ Production-oriented evaluation.
787
+ Based on HN practitioner recommendations.
788
+ """
789
+ results = {
790
+ "before": [],
791
+ "after": [],
792
+ "human_preference": []
793
+ }
794
+
795
+ for task in task_set:
796
+ # Run both agents
797
+ before_result = before_agent.execute(task)
798
+ after_result = after_agent.execute(task)
799
+
800
+ # Objective metrics (NOT LLM-judged)
801
+ results["before"].append({
802
+ "tests_pass": run_tests(before_result),
803
+ "lint_clean": run_linter(before_result),
804
+ "time_taken": before_result.duration,
805
+ "tokens_used": before_result.tokens
806
+ })
807
+
808
+ results["after"].append({
809
+ "tests_pass": run_tests(after_result),
810
+ "lint_clean": run_linter(after_result),
811
+ "time_taken": after_result.duration,
812
+ "tokens_used": after_result.tokens
813
+ })
814
+
815
+ # Sample for human review
816
+ if random.random() < 0.1: # 10% sample
817
+ results["human_preference"].append({
818
+ "task": task,
819
+ "before": before_result,
820
+ "after": after_result,
821
+ "pending_review": True
822
+ })
823
+
824
+ return EvaluationReport(results)
825
+ ```
826
+
827
+ ---
828
+
829
+ ## Cost and Token Economics
830
+
831
+ ### Real-World Cost Patterns
832
+
833
+ ```yaml
834
+ cost_patterns:
835
+ claude_code:
836
+ heavy_use: "$25/1-2 hours on large codebases"
837
+ api_range: "$1-5/hour depending on efficiency"
838
+ max_tier: "$200/month often needs 2-3 subscriptions"
839
+
840
+ token_economics:
841
+ sub_agents_multiply_cost: "Each duplicates context"
842
+ example: "5-task parallel job = 50,000+ tokens per subtask"
843
+
844
+ optimization:
845
+ context_isolation: "Use sub-agents for noisy tasks"
846
+ information_abstraction: "Summarize, don't dump"
847
+ fresh_conversations: "Reset after major tasks"
848
+ skill_on_demand: "Load only when needed"
849
+ ```
850
+
851
+ ---
852
+
853
+ ## Cross-Process File Lock (v7.5.5)
854
+
855
+ Concurrent loki invocations on the same `.loki/` workspace previously raced on `state/orchestrator.json`, `queue/pending.json`, and CONTINUITY.md. v7.5.5 introduces a `flock`-backed cross-process lock around all state writes. Concurrent runs serialize state mutations cleanly; readers continue without blocking.
856
+
857
+ ---
858
+
859
+ ## Sources
860
+
861
+ **Hacker News Discussions:**
862
+ - [What Actually Works in Production for Autonomous Agents](https://news.ycombinator.com/item?id=44623207)
863
+ - [Coding with LLMs in Summer 2025](https://news.ycombinator.com/item?id=44623953)
864
+ - [Superpowers: How I'm Using Coding Agents](https://news.ycombinator.com/item?id=45547344)
865
+ - [Claude Code Experience After Two Weeks](https://news.ycombinator.com/item?id=44596472)
866
+ - [AI Agent Benchmarks Are Broken](https://news.ycombinator.com/item?id=44531697)
867
+ - [How to Orchestrate Multi-Agent Workflows](https://news.ycombinator.com/item?id=45955997)
868
+ - [Context Engineering vs Prompt Engineering](https://news.ycombinator.com/item?id=44427757)
869
+
870
+ **Show HN Projects:**
871
+ - [Self-Evolving Agents Repository](https://news.ycombinator.com/item?id=45099226)
872
+ - [Package Manager for Agent Skills](https://news.ycombinator.com/item?id=46422264)
873
+ - [Wispbit - AI Code Review Agent](https://news.ycombinator.com/item?id=44722603)
874
+ - [Agtrace - Monitoring for AI Coding Agents](https://news.ycombinator.com/item?id=46425670)
875
+
876
+ ---
877
+
277
878
  References: `references/deployment.md` (infrastructure and deployment by platform), `references/task-queue.md` (task queue, dead letters, circuit breakers).