Skip to content

Commit c22b38f

Browse files
committed
fix: session resume, resource loading, and error path consistency
- don't advance resume cursor past failed must_complete tasks - peek at last tool result before consuming (safe for retry) - use Traversable.open() for zip/wheel compatibility - return empty string (not None) for prompt on invalid globals
1 parent 6859474 commit c22b38f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/seclab_taskflow_agent/available_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _load(self, tooltype: AvailableToolType, toolname: str) -> DocumentModel:
121121
f"Cannot load {toolname} because {pkg_dir} is not a valid directory."
122122
)
123123
filepath = pkg_dir.joinpath(filename + ".yaml")
124-
with open(filepath) as fh:
124+
with filepath.open() as fh:
125125
raw = yaml.safe_load(fh)
126126

127127
# Validate header before full parse

src/seclab_taskflow_agent/prompt_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def parse_prompt_args(
6666
for g in args[0].globals:
6767
if "=" not in g:
6868
logging.error(f"Invalid global variable format: {g}. Expected KEY=VALUE")
69-
return None, None, None, None, None, help_msg
69+
return None, None, None, None, "", help_msg
7070
key, value = g.split("=", 1)
7171
cli_globals[key.strip()] = value.strip()
7272

src/seclab_taskflow_agent/runner.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def _build_prompts_to_run(
198198
if "result" not in task_prompt.lower():
199199
logging.warning("repeat_prompt enabled but no {{ result }} in prompt")
200200
try:
201-
last_result = json.loads(last_mcp_tool_results.pop())
201+
last_result = json.loads(last_mcp_tool_results[-1])
202202
text = last_result.get("text", "")
203203
try:
204204
iterable_result = json.loads(text)
@@ -214,6 +214,9 @@ async def _build_prompts_to_run(
214214
logging.critical("No last MCP tool result available")
215215
raise
216216

217+
# Consume only after successful parse
218+
last_mcp_tool_results.pop()
219+
217220
if not iterable_result:
218221
await render_model_output("** 🤖❗MCP tool result iterable is empty!\n")
219222
else:
@@ -689,14 +692,6 @@ async def _deploy(ra: dict, pp: str) -> bool:
689692
)
690693
raise last_task_error
691694

692-
# Checkpoint after successful task
693-
session.record_task(
694-
index=task_index,
695-
name=task_name,
696-
success=task_complete,
697-
tool_results=list(last_mcp_tool_results),
698-
)
699-
700695
if must_complete and not task_complete:
701696
logging.critical("Required task not completed ... aborting!")
702697
await render_model_output("🤖💥 *Required task not completed ...\n")
@@ -707,6 +702,15 @@ async def _deploy(ra: dict, pp: str) -> bool:
707702
)
708703
break
709704

705+
# Checkpoint after task (must_complete failures break above
706+
# without advancing the resume cursor)
707+
session.record_task(
708+
index=task_index,
709+
name=task_name,
710+
success=task_complete,
711+
tool_results=list(last_mcp_tool_results),
712+
)
713+
710714
# All tasks completed successfully
711715
if session is not None and not session.error:
712716
session.mark_finished()

0 commit comments

Comments
 (0)