fix: ruff formatting and mypy type error

Run ruff format on agent_tui.py, cli.py, executor.py. Fix agents_dir
argument type: pass Path object instead of str to match the
load_agent_from_definition signature (Path | None).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Joao Moura
2026-05-14 17:48:30 -04:00
parent 1c6a190046
commit db604b6f32
3 changed files with 18 additions and 13 deletions

View File

@@ -1124,7 +1124,9 @@ class AgentTUI(App[None]):
lines = [f"[bold]Active Skills[/] ({len(active)})"]
for s in active:
lines.append(f" [{_CORAL}]{_safe_render(s.name)}[/] — {_safe_render(s.description)}")
lines.append(
f" [{_CORAL}]{_safe_render(s.name)}[/] — {_safe_render(s.description)}"
)
self._mount_sys("\n".join(lines))
def _handle_tasks_command(self, parts: list[str]) -> None:
@@ -1223,7 +1225,9 @@ class AgentTUI(App[None]):
if mem_type == "canonical"
else f"[dim]{mem_type}[/]"
)
importance_tag = f" [yellow]★{_safe_render(str(importance))}[/]" if importance else ""
importance_tag = (
f" [yellow]★{_safe_render(str(importance))}[/]" if importance else ""
)
scope_tag = f" [{_DIM}]scope:{_safe_render(str(scope))}[/]" if scope else ""
time_tag = f" [{_DIM}]{timestamp}[/]" if timestamp else ""

View File

@@ -236,7 +236,7 @@ def _train_new_agents(agent_files: list[Any], n_iterations: int) -> None:
from crewai.new_agent.definition_parser import load_agent_from_definition
agent = load_agent_from_definition(
str(agent_path), agents_dir=str(agent_path.parent)
str(agent_path), agents_dir=agent_path.parent
)
except Exception as e:
click.secho(f" Error loading agent {agent_name}: {e}", fg="red")
@@ -992,7 +992,9 @@ def _test_new_agents(
if progress is None:
raise RuntimeError("progress must not be None in non-verbose mode")
progress.start(iteration=iteration)
output_ctx = VerboseBenchmarkOutput() if verbose else SuppressBenchmarkOutput()
output_ctx = (
VerboseBenchmarkOutput() if verbose else SuppressBenchmarkOutput()
)
with ArtifactsSandbox(), output_ctx:
all_results = _loop.run_until_complete(_run_all())
finally:

View File

@@ -625,9 +625,7 @@ class ConversationalAgentExecutor(BaseModel):
pass
return ""
_INTERNAL_TAG_RE = re.compile(
r"<summary>.*?</summary>", re.DOTALL
)
_INTERNAL_TAG_RE = re.compile(r"<summary>.*?</summary>", re.DOTALL)
def _strip_internal_tags(self, text: str) -> str:
"""Strip <summary> blocks that leak from the summarization prompt."""
@@ -2034,7 +2032,9 @@ class ConversationalAgentExecutor(BaseModel):
)
self.provenance_log.append(tool_prov_entry)
# GAP-89: Persist tool call provenance to memory
await asyncio.to_thread(self._persist_provenance_to_memory, tool_prov_entry)
await asyncio.to_thread(
self._persist_provenance_to_memory, tool_prov_entry
)
# GAP-67: Detect artifacts from tool results
try:
@@ -2065,11 +2065,10 @@ class ConversationalAgentExecutor(BaseModel):
if len(result_str) > _MAX_TOOL_RESULT_CHARS:
from crewai.utilities.i18n import I18N_DEFAULT
display_result = (
result_str[:_MAX_TOOL_RESULT_CHARS]
+ I18N_DEFAULT.new_agent("tool_result_truncated").format(
char_count=len(result_str)
)
display_result = result_str[
:_MAX_TOOL_RESULT_CHARS
] + I18N_DEFAULT.new_agent("tool_result_truncated").format(
char_count=len(result_str)
)
llm_messages.append(
{