trading_agent.extensions.untrusted_text
¶
Labels text from outside trading-agent as data before the model reads it.
Web pages, search results, browser snapshots, MCP output, knowledge-base passages and the user's imported skills all reach the model through tools. Each is wrapped between two marker lines saying where it came from and that it is data, not instructions. Invisible characters are removed, and if the injection scanner finds something, a warning naming what it found is added at the top.
Typical usage example:
text = UntrustedText().wrap('web page https://example.com', page_text)
UntrustedText
¶
Wraps outside text for the model.
Creates the wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scanner
|
InjectionScanner | None
|
The scanner to use, or None for a new one. |
None
|
Source code in src/trading_agent/extensions/untrusted_text.py
wrap
¶
Labels one piece of outside text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Where it came from, such as "web page https://example.com". |
required |
text
|
str
|
The text. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The text between marker lines, without invisible characters, with a warning first when the scanner found something. |