mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-02-01 23:13:36 +00:00
refactor: optimize token usage, deduplicate code, fix bugs across agents
Token reduction (~40% per session, ~2.3M fewer tokens per 200-feature project): - Agent-type-specific tool lists: coding 9, testing 5, init 5 (was 19 for all) - Right-sized max_turns: coding 300, testing 100 (was 1000 for all) - Trimmed coding prompt template (~150 lines removed) - Streamlined testing prompt with batch support - YOLO mode now strips browser testing instructions from prompt - Added Grep, WebFetch, WebSearch to expand project session Performance improvements: - Rate limit retries start at ~15s with jitter (was fixed 60s) - Post-spawn delay reduced to 0.5s (was 2s) - Orchestrator consolidated to 1 DB query per loop (was 5-7) - Testing agents batch 3 features per session (was 1) - Smart context compaction preserves critical state, discards noise Bug fixes: - Removed ghost feature_release_testing MCP tool (wasted tokens every test session) - Forward all 9 Vertex AI env vars to chat sessions (was missing 3) - Fix DetachedInstanceError risk in test batch ORM access - Prevent duplicate testing of same features in parallel mode Code deduplication: - _get_project_path(): 9 copies -> 1 shared utility (project_helpers.py) - validate_project_name(): 9 copies -> 2 variants in 1 file (validation.py) - ROOT_DIR: 10 copies -> 1 definition (chat_constants.py) - API_ENV_VARS: 4 copies -> 1 source of truth (env_constants.py) Security hardening: - Unified sensitive directory blocklist (14 dirs, was two divergent lists) - Cached get_blocked_paths() for O(1) directory listing checks - Terminal security warning when ALLOW_REMOTE=1 exposes WebSocket - 20 new security tests for EXTRA_READ_PATHS blocking - Extracted _validate_command_list() and _validate_pkill_processes() helpers Type safety: - 87 mypy errors -> 0 across 58 source files - Installed types-PyYAML for proper yaml stub types - Fixed SQLAlchemy Column[T] coercions across all routers Dead code removed: - 13 files deleted (~2,679 lines): unused UI components, debug logs, outdated docs - 7 unused npm packages removed (Radix UI components with 0 imports) - AgentAvatar.tsx reduced from 615 -> 119 lines (SVGs extracted to mascotData.tsx) New CLI options: - --testing-batch-size (1-5) for parallel mode test batching - --testing-feature-ids for direct multi-feature testing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -145,7 +145,14 @@ Authentication:
|
||||
"--testing-feature-id",
|
||||
type=int,
|
||||
default=None,
|
||||
help="Feature ID to regression test (used by orchestrator for testing agents)",
|
||||
help="Feature ID to regression test (used by orchestrator for testing agents, legacy single mode)",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--testing-feature-ids",
|
||||
type=str,
|
||||
default=None,
|
||||
help="Comma-separated feature IDs to regression test in batch (e.g., '5,12,18')",
|
||||
)
|
||||
|
||||
# Testing agent configuration
|
||||
@@ -156,6 +163,13 @@ Authentication:
|
||||
help="Testing agents per coding agent (0-3, default: 1). Set to 0 to disable testing agents.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--testing-batch-size",
|
||||
type=int,
|
||||
default=3,
|
||||
help="Number of features per testing batch (1-5, default: 3)",
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -199,6 +213,15 @@ def main() -> None:
|
||||
if migrated:
|
||||
print(f"Migrated project files to .autocoder/: {', '.join(migrated)}", flush=True)
|
||||
|
||||
# Parse batch testing feature IDs (comma-separated string -> list[int])
|
||||
testing_feature_ids: list[int] | None = None
|
||||
if args.testing_feature_ids:
|
||||
try:
|
||||
testing_feature_ids = [int(x.strip()) for x in args.testing_feature_ids.split(",") if x.strip()]
|
||||
except ValueError:
|
||||
print(f"Error: --testing-feature-ids must be comma-separated integers, got: {args.testing_feature_ids}")
|
||||
return
|
||||
|
||||
try:
|
||||
if args.agent_type:
|
||||
# Subprocess mode - spawned by orchestrator for a specific role
|
||||
@@ -211,6 +234,7 @@ def main() -> None:
|
||||
feature_id=args.feature_id,
|
||||
agent_type=args.agent_type,
|
||||
testing_feature_id=args.testing_feature_id,
|
||||
testing_feature_ids=testing_feature_ids,
|
||||
)
|
||||
)
|
||||
else:
|
||||
@@ -229,6 +253,7 @@ def main() -> None:
|
||||
model=args.model,
|
||||
yolo_mode=args.yolo,
|
||||
testing_agent_ratio=args.testing_ratio,
|
||||
testing_batch_size=args.testing_batch_size,
|
||||
)
|
||||
)
|
||||
except KeyboardInterrupt:
|
||||
|
||||
Reference in New Issue
Block a user