Package com.tnsai.thread


package com.tnsai.thread
Thread-based execution model for TnsAI agents.

This package provides a thread-based execution model that enables:

  • Session-scoped conversations with state persistence
  • Parent-child thread hierarchies for complex workflows
  • Resource quotas and backpressure management
  • Pause/resume and crash recovery
  • Thread lifecycle management

Key Classes

Usage Example


 // Create a thread manager
 ThreadManager manager = new ThreadManager(checkpointer);

 // Create a new thread
 AgentThread thread = manager.createThread(ThreadSpec.builder()
     .maxTokens(100000)
     .maxToolCalls(50)
     .timeout(Duration.ofMinutes(30))
     .build());

 // Execute within thread context
 String response = thread.execute(agent, "Hello!");

 // Pause and resume
 thread.pause();
 // ... later ...
 thread.resume();

 // Create child thread for sub-task
 AgentThread childThread = thread.createChild(childSpec);
 
Since:
0.0.2