Class SkillSession

java.lang.Object
com.tnsai.skills.SkillSession

public final class SkillSession extends Object
Per-agent runtime state for the skill layer (TNS-289). Tracks which skills the agent has activated during the current session so the full bodies can be persistently appended to the system prompt after the first invocation.

The session deliberately decouples activation order (insertion order, mirrored via LinkedHashMap) from registration order — the first invocation of a skill is what defines its position in the prompt, matching Claude Code's behaviour.

Concurrency

The session is shared by every dispatch on the same agent and skill activation is rare relative to chat turns, so a coarse ReentrantLock is fine — fewer concurrency bugs to chase than a striped or lock-free design.
Since:
0.10.0
  • Constructor Details

    • SkillSession

      public SkillSession()
  • Method Details

    • activate

      public ActiveSkill activate(Skill skill, List<String> arguments, Map<String,String> environment)
      Activate skill with the supplied arguments and environment. Re-activating an already-active skill REPLACES the previous snapshot — the latest invocation's substituted body wins.
    • deactivate

      public Optional<ActiveSkill> deactivate(String name)
      Detach an active skill — its body is no longer appended to the system prompt. Returns the snapshot if one was present.
    • activeSkills

      public List<ActiveSkill> activeSkills()
      Snapshot of currently active skills, in activation order.
    • isActive

      public boolean isActive(String name)
      True if a skill with the given (case-insensitive) name is active.
    • clear

      public void clear()
      Drop every active skill. Useful for tests and for conversation resets.