44import asyncio
55import json
66from typing import (
7- Optional ,
87 TYPE_CHECKING ,
9- Tuple ,
10- List ,
11- Dict ,
128 Any ,
13- TypeVar ,
149 Callable ,
10+ Dict ,
1511 Generic ,
12+ List ,
13+ Optional ,
14+ Tuple ,
15+ TypeVar ,
1616)
1717
1818import aiortc
19+ from vision_agents .core .instructions import Instructions
1920from vision_agents .core .llm import events
20- from vision_agents .core .llm .events import ToolStartEvent , ToolEndEvent
21+ from vision_agents .core .llm .events import ToolEndEvent , ToolStartEvent
2122
2223if TYPE_CHECKING :
2324 from vision_agents .core .agents import Agent
2425 from vision_agents .core .agents .conversation import Conversation
2526
26- from getstream .video .rtc .pb .stream .video .sfu .models .models_pb2 import Participant
2727from getstream .video .rtc import PcmData
28- from vision_agents .core .processors import Processor
29- from vision_agents .core .utils .utils import Instructions , parse_instructions
28+ from getstream .video .rtc .pb .stream .video .sfu .models .models_pb2 import Participant
3029from vision_agents .core .events .manager import EventManager
31- from . function_registry import FunctionRegistry
32- from . llm_types import ToolSchema , NormalizedToolCallItem
30+ from vision_agents . core . processors import Processor
31+
3332from ..utils .video_forwarder import VideoForwarder
33+ from .function_registry import FunctionRegistry
34+ from .llm_types import NormalizedToolCallItem , ToolSchema
3435
3536T = TypeVar ("T" )
3637
@@ -58,8 +59,8 @@ def __init__(self):
5859 self .events = EventManager ()
5960 self .events .register_events_from_module (events )
6061 self .function_registry = FunctionRegistry ()
61- self . instructions : Optional [ str ] = None
62- self .parsed_instructions : Optional [ Instructions ] = None
62+ # LLM instructions. Provided by the Agent via `set_instructions` method
63+ self ._instructions : str = ""
6364 self ._conversation : Optional [Conversation ] = None
6465
6566 async def warmup (self ) -> None :
@@ -80,34 +81,6 @@ async def simple_response(
8081 ) -> LLMResponseEvent [Any ]:
8182 raise NotImplementedError
8283
83- def _build_enhanced_instructions (self ) -> Optional [str ]:
84- """
85- Build enhanced instructions by combining the original instructions with markdown file contents.
86-
87- Returns:
88- Enhanced instructions string with markdown file contents included, or None if no parsed instructions
89- """
90- if not hasattr (self , "parsed_instructions" ) or not self .parsed_instructions :
91- return None
92-
93- parsed = self .parsed_instructions
94- enhanced_instructions = [parsed .input_text ]
95-
96- # Add markdown file contents if any exist
97- if parsed .markdown_contents :
98- enhanced_instructions .append ("\n \n ## Referenced Documentation:" )
99- for filename , content in parsed .markdown_contents .items ():
100- if content : # Only include non-empty content
101- enhanced_instructions .append (f"\n ### { filename } " )
102- enhanced_instructions .append (content )
103- else :
104- enhanced_instructions .append (f"\n ### { filename } " )
105- enhanced_instructions .append (
106- "*(File not found or could not be read)*"
107- )
108-
109- return "\n " .join (enhanced_instructions )
110-
11184 def _get_tools_for_provider (self ) -> List [Dict [str , Any ]]:
11285 """
11386 Get tools in provider-specific format.
@@ -189,7 +162,7 @@ def _attach_agent(self, agent: Agent):
189162 Attach agent to the llm
190163 """
191164 self .agent = agent
192- self ._set_instructions (agent .instructions )
165+ self .set_instructions (agent .instructions )
193166
194167 def set_conversation (self , conversation : Conversation ):
195168 """
@@ -203,11 +176,8 @@ def set_conversation(self, conversation: Conversation):
203176 """
204177 self ._conversation = conversation
205178
206- def _set_instructions (self , instructions : str ):
207- self .instructions = instructions
208-
209- # Parse instructions to extract @ mentioned markdown files
210- self .parsed_instructions = parse_instructions (instructions )
179+ def set_instructions (self , instructions : Instructions ):
180+ self ._instructions = instructions .full_reference
211181
212182 def register_function (
213183 self , name : Optional [str ] = None , description : Optional [str ] = None
0 commit comments