LLMAgent.run_with_skill() explicitly requests a named skill. It accepts a required skill_name and optional prompt and max_steps, builds a task instruction, then delegates execution to run(). section 6.4.4
The instruction directs the LLM to call UseSkillTool with the specified skill name. This explicit route bypasses the name enum in the tool's parameter schema; UseSkillTool validation is relaxed accordingly. section 6.4.4
Listing 6.17 Implementing LLMAgent: run_with_skill()
# llm_agents_from_scratch/agent/llm_agent.py
… #A
from llm_agents_from_scratch.skills.constants import (
EXPLICIT_SKILL_ACTIVATION_TEMPLATE,
EXPLICIT_SKILL_ACTIVATION_WITH_PROMPT_TEMPLATE
)
class LLMAgent:
… #B
def run_with_skill(
self,
skill_name: str,
prompt: str | None = None,
max_steps: int | None = None,
) -> TaskHandler:
"""User-explicit skill activation.""" #C
if prompt: #D
instruction = EXPLICIT_SKILL_ACTIVATION_WITH_PROMPT_TEMPLATE.format(
name=skill_name,
prompt=prompt,
)
else:
instruction = EXPLICIT_SKILL_ACTIVATION_TEMPLATE.format(
name=skill_name,
)
task = Task(instruction=instruction)
return self.run(task=task, max_steps=max_steps) #EImplementation showing prompt-dependent instruction templates and delegation to run(). section 6.4.4
Explicit skill invocation
An example invokes the obfuscated Hailstone skill through run_with_skill(). section 6.4.4
