feat(token-viz): Phase 1 — token budget panel with color bar and breakdown table
This commit is contained in:
@@ -125,7 +125,7 @@ def get_dependencies(filepath: str) -> list[str]:
|
||||
print(f"Error getting dependencies for {filepath}: {e}")
|
||||
return []
|
||||
|
||||
def execute_agent(role: str, prompt: str, docs: list[str]) -> str:
|
||||
def execute_agent(role: str, prompt: str, docs: list[str], timeout: int | None = None) -> str:
|
||||
model = get_model_for_role(role)
|
||||
# Advanced Context: Dependency skeletons for Tier 3
|
||||
injected_context = ""
|
||||
@@ -205,6 +205,7 @@ def execute_agent(role: str, prompt: str, docs: list[str]) -> str:
|
||||
text=True,
|
||||
encoding='utf-8',
|
||||
env=env,
|
||||
timeout=timeout,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if hasattr(subprocess, 'CREATE_NO_WINDOW') else 0,
|
||||
)
|
||||
# claude --print outputs plain text — no JSON parsing needed
|
||||
@@ -212,6 +213,10 @@ def execute_agent(role: str, prompt: str, docs: list[str]) -> str:
|
||||
log_file = log_delegation(role, command_text, result, summary_prompt=prompt)
|
||||
print(f"Sub-agent log created: {log_file}")
|
||||
return result
|
||||
except subprocess.TimeoutExpired:
|
||||
err_msg = f"Execution timed out after {timeout}s"
|
||||
log_delegation(role, command_text, err_msg)
|
||||
return err_msg
|
||||
except Exception as e:
|
||||
err_msg = f"Execution failed: {str(e)}"
|
||||
log_delegation(role, command_text, err_msg)
|
||||
@@ -230,6 +235,12 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
type=str,
|
||||
help="TOML file defining the task"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--timeout",
|
||||
type=int,
|
||||
default=None,
|
||||
help="Subprocess timeout in seconds (default: no timeout)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"prompt",
|
||||
type=str,
|
||||
@@ -261,7 +272,7 @@ def main() -> None:
|
||||
if os.path.exists(ref) and ref not in docs:
|
||||
docs.append(ref)
|
||||
print(f"Executing role: {role} with docs: {docs}")
|
||||
result = execute_agent(role, prompt, docs)
|
||||
result = execute_agent(role, prompt, docs, timeout=args.timeout)
|
||||
print(result)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user