MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / peek_task_name

Function peek_task_name

src/harness/paths.py:86–113  ·  view source on GitHub ↗

Read the top-level ``name:`` key from a workflow YAML without full parse. We need the task name *before* the harness runs YAML env-var expansion (because the injected ``AGENTSPEX_RUN_*`` env vars depend on the task name). A lightweight scan avoids the chicken-and-egg problem of needing

(workflow_file: Optional[str])

Source from the content-addressed store, hash-verified

84
85
86def peek_task_name(workflow_file: Optional[str]) -> Optional[str]:
87 """Read the top-level ``name:`` key from a workflow YAML without full parse.
88
89 We need the task name *before* the harness runs YAML env-var expansion
90 (because the injected ``AGENTSPEX_RUN_*`` env vars depend on the task
91 name). A lightweight scan avoids the chicken-and-egg problem of needing
92 the env vars to parse the YAML that tells us the task name.
93 """
94 if not workflow_file:
95 return None
96 try:
97 with open(workflow_file, "r", encoding="utf-8") as f:
98 for raw in f:
99 line = raw.strip()
100 if not line or line.startswith("#"):
101 continue
102 if line.startswith("name:"):
103 value = line.split(":", 1)[1].strip().strip('"').strip("'")
104 value = os.path.expandvars(value)
105 return value or None
106 # ``name:`` is conventionally the first non-comment key. If we
107 # encounter any other top-level key first, stop — better to
108 # fall back to the filename than misread a nested key.
109 if line and not line.startswith((" ", "\t", "-")):
110 break
111 except Exception:
112 return None
113 return None
114
115
116_RUN_ENV_KEYS = (

Callers 2

mainFunction · 0.90
run_ephemeralFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected