liveBook · Manning

Run_with_skill()

As explained in Build a Multi-Agent System (from Scratch)

run_with_skill() is the example framework's LLMAgent method for explicitly invoking a named skill with an optional prompt and step limit.

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) #E

Implementation 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

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Defines the method signature and task-instruction flow, but does not detail the skill's execution internals.
Examples
Demonstrates explicit invocation of the obfuscated Hailstone skill.
What it assumes
Requires a skill name; accepts a prompt and step limit as optional inputs.
What you can do after
Apply run_with_skill() to request a named skill, optionally supplying a prompt and step limit.
How it connects
Connects LLMAgent and Task to run(), TaskHandler, UseSkillTool, and skill activation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.