Skip to content

Connect Secureframe to AI Agents: Sync Evidence and Knowledge Bases

Learn how to connect Secureframe to AI Agents using Truto's proxy APIs. Automate compliance evidence, manage risk registers, and handle complex API quirks like Lucene syntax and rate limits natively.

Uday Gajavalli Uday Gajavalli · · 9 min read
Connect Secureframe to AI Agents: Sync Evidence and Knowledge Bases

You want to connect Secureframe to an AI agent so your systems can autonomously answer security questionnaires, sync compliance evidence, audit cloud resource scopes, and manage vendor risks based on historical context. Here is exactly how to do it using Truto's /tools endpoint and SDK, bypassing the need to maintain an ever-changing compliance API wrapper manually.

Giving a Large Language Model (LLM) read and write access to your Compliance and Security platform is an engineering risk if handled poorly. You either spend months building, securing, and maintaining a custom Secureframe connector, or you use a managed infrastructure layer that handles the boilerplate for you while maintaining zero data retention for AI agents. If your team uses ChatGPT, check out our guide on connecting Secureframe to ChatGPT, or if you are building on Anthropic's models, read our guide on connecting Secureframe to Claude. For developers building custom autonomous workflows, you need a programmatic way to fetch these tools and bind them to your agent framework.

This guide breaks down exactly how to fetch AI-ready tools for Secureframe, bind them natively to an LLM using LangChain (or frameworks like LangGraph, CrewAI, or the Vercel AI SDK), and execute complex compliance operations autonomously. For a deeper look at the architecture behind this approach, refer to our research on architecting AI agents and the SaaS integration bottleneck.

The Engineering Reality of Custom Secureframe Connectors

Building AI agents is easy. Connecting them to external SaaS APIs safely is hard. If you decide to build a custom integration for Secureframe, you own the entire API lifecycle. Secureframe's API introduces several specific integration challenges that break standard LLM assumptions and naive agent implementations.

The Lucene Search Syntax Hurdle

Many of Secureframe's core endpoints - such as listing repositories, cloud resources, comments, or controls - rely heavily on the q parameter for filtering. However, this is not a standard key-value query parameter. Secureframe requires standard Lucene syntax for these queries.

When an AI agent wants to find a specific failing control or an out-of-scope AWS resource, it cannot simply pass ?health_status=failing. It must format the query as a Lucene string, such as ?q=health_status:failing AND enabled:true. Large Language Models consistently fail at constructing valid Lucene queries unless the tool schema strictly enforces the format and provides detailed instructions. If you hand-code this integration, you are forced to inject heavy prompt engineering into your system instructions just to get the LLM to search correctly. Truto's proxy API tool schemas handle this abstraction by providing clear parameter definitions directly to the model.

Immutable Asset Scopes

Secureframe enforces strict audit trails. A prime example is the Framework Asset Scope. When you want to modify the scope of a cloud resource or a device, you do not update the existing scope record. Framework Asset Scopes are entirely immutable. Once created, they cannot be modified via a PUT or PATCH request.

To change a scope, the agent must create a completely new scope record targeting the same resource. Naive AI agents, when asked to "update the scope of the staging database to out of scope," will almost always attempt to infer an update endpoint or pass an ID to a PATCH method, resulting in an immediate 400 Bad Request or 405 Method Not Allowed. The tool definitions must explicitly document this immutability so the agent knows to use the creation endpoint to reflect the new state.

The 202 Accepted Trap on Custom Connections

When passing arbitrary resource data into Secureframe via a custom connection (such as pushing bespoke internal server logs for compliance tracking), the API processes this data asynchronously. The create_a_secureframe_custom_connection_datum endpoint accepts the payload and immediately returns an HTTP 202 Accepted response with no response body.

AI agents despise empty responses. Standard tool calling loops expect a JSON payload back confirming the state of the entity they just manipulated. When the agent receives a 202 with an empty body, it frequently hallucinates a successful JSON response or errors out trying to parse a null payload. Your execution layer must intercept this 202 state and translate it into a structured "Action enqueued successfully" message for the LLM to process.

Fetching Secureframe Tools via Truto

Instead of writing and maintaining OpenAPI specs for every Secureframe endpoint, Truto provides a /tools API. Every integration on Truto maps underlying API endpoints to REST-based Proxy APIs. Truto handles the pagination, authentication, and query parameter processing, exposing these methods directly to your LLM via standard function calling.

To fetch the tools, you query the Truto API using your Integrated Account ID.

curl -X GET "https://api.truto.one/integrated-account/<secureframe_account_id>/tools" \
  -H "Authorization: Bearer YOUR_TRUTO_API_KEY"

This returns a massive JSON object containing OpenAI-compatible tool schemas. You can even filter these by passing query parameters like ?methods [0]=read if you want to provide your agent with a strictly read-only view of your compliance posture.

Handling Rate Limits

It is a factual reality that AI agents can be incredibly aggressive when querying APIs, especially during pagination loops or bulk evidence retrieval. Truto does not retry, throttle, or apply backoff on rate limit errors.

When Secureframe returns an HTTP 429, Truto passes that error directly to the caller. However, Truto normalizes the upstream rate limit information into standardized headers across all integrations:

  • ratelimit-limit: The maximum number of requests allowed in the window.
  • ratelimit-remaining: How many requests you have left.
  • ratelimit-reset: The time (in seconds) until the limit resets.

Your agent execution loop is responsible for reading these headers, pausing execution, and retrying the proxy API call. Do not assume the infrastructure will magically absorb these errors.

Essential Secureframe AI Agent Tools

Here are the most high-leverage tools available for Secureframe when building automated compliance workflows.

list_all_secureframe_controls

This tool allows the agent to fetch the active compliance controls across your organization. It supports Lucene syntax filtering, making it trivial for the agent to isolate controls that are currently failing or unassigned.

"Find all Secureframe controls assigned to John Doe that currently have a failing health status."

list_all_secureframe_cloud_resources

Agents use this tool to audit your cloud infrastructure footprint. It returns vital metadata including vendor names, regions, and whether the asset is currently in the audit scope.

"List all cloud resources in the us-east-1 region that are currently out of the audit scope."

create_a_secureframe_cloud_resource_framework_asset_scope

Because scopes are immutable, this tool is the exclusive way for an agent to alter the audit status of a cloud resource. The agent uses this to programmatically bring shadow IT into scope or justify removing a test database from the audit boundary.

"Set the audit scope of cloud resource 'db-staging-eu' to out of scope and provide the reason 'Ephemeral test database'."

get_single_secureframe_knowledge_base_answer_by_id

When responding to vendor security questionnaires, the agent needs to retrieve your canonical security posture. This tool fetches the specific approved answer for a documented security question.

"Retrieve the knowledge base answer for question ID 84920 to check our official policy on at-rest encryption."

create_a_secureframe_knowledge_base_answer

When a new security question arises that isn't in the knowledge base, the agent can draft an answer based on your internal documentation and submit it to Secureframe for human review.

"Create a new knowledge base answer for question ID 9102 stating that our target SLA for critical vulnerabilities is 24 hours."

create_a_secureframe_test_evidence

Evidence collection is the bane of engineering teams. This tool allows the agent to attach multipart file evidence (like screenshots of AWS configurations or export logs) directly to a specific Secureframe test.

"Upload the provided S3 bucket configuration JSON file as evidence for the 'S3 Public Access Block' test."

For the complete inventory of available Secureframe tools and their precise JSON schemas, visit the Secureframe integration page.

Workflows in Action

Agentic compliance requires chaining multiple tools together to accomplish a business goal. Here are two real-world scenarios showing how an agent utilizes the Secureframe tools.

Scenario 1: Auto-Remediating Out-of-Scope Cloud Assets

Shadow IT constantly spins up new infrastructure. You want your AI agent to monitor new resources and automatically attach the correct audit scopes to them.

"Find any new AWS RDS instances in the us-west-2 region that are currently out of audit scope, and bring them into the SOC 2 framework scope."

  1. list_all_secureframe_cloud_resources: The agent queries the API using Lucene syntax (q=vendor_name:aws AND region:us-west-2 AND in_audit_scope:false) to retrieve the offending resources.
  2. list_all_secureframe_frameworks: The agent retrieves the internal ID for the SOC 2 framework.
  3. create_a_secureframe_cloud_resource_framework_asset_scope: For each resource ID found in step 1, the agent creates a new immutable scope record linking the resource to the SOC 2 framework ID, setting it to active.

Result: The agent autonomously moves untracked shadow databases into the active audit scope without human intervention.

Scenario 2: Autonomous Security Questionnaire Responses

Sales teams spend hours filling out identical security questionnaires. An agent can automate this by querying your established knowledge base.

"We received a security questionnaire asking about our password rotation policy. Find our standard answer in Secureframe and draft an email response."

  1. list_all_secureframe_knowledge_base_questions: The agent searches for questions containing the keywords "password rotation".
  2. get_single_secureframe_knowledge_base_answer_by_id: The agent extracts the ID from the previous step and retrieves the primary approved answer content.
  3. LLM Internal Processing: The agent formats the raw answer into a professional, customer-facing email draft.

Result: The user gets a perfectly formatted response based strictly on the immutable, approved knowledge base stored in Secureframe, eliminating hallucination risks.

Building Multi-Step Workflows

To build a resilient agent, you need to bind the Truto tools to your LLM and handle the execution loop. We strongly recommend using the TrutoToolManager from the truto-langchainjs-toolset package. It abstracts the tool fetching and binding process, while leaving you in complete control of the execution flow and error handling.

Here is a complete, framework-agnostic architectural flow for an agent interacting with Secureframe:

flowchart TD
    User["User Prompt<br>('Find failing controls')"]
    LLM["LLM Agent<br>(LangChain/LangGraph)"]
    TrutoTools["Truto Tool Manager<br>(Proxy API)"]
    Secureframe["Secureframe API"]

    User --> LLM
    LLM -->|"Invokes list_controls tool"| TrutoTools
    TrutoTools -->|"HTTP GET"| Secureframe
    
    Secureframe --x|"HTTP 429 Rate Limit"| TrutoTools
    TrutoTools -->|"Throws Error with<br>ratelimit-reset header"| LLM
    LLM -->|"Waits & Retries"| TrutoTools
    TrutoTools -->|"HTTP GET"| Secureframe
    Secureframe -->|"200 OK + JSON"| TrutoTools
    TrutoTools -->|"Tool Output"| LLM
    LLM -->|"Final Answer"| User

The TypeScript Implementation

Below is a working implementation using LangChain.js. Notice how we explicitly handle the HTTP 429 rate limit scenario, extracting the ratelimit-reset header. Since Truto does not retry automatically, this is a mandatory step for production-grade compliance agents.

import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "truto-langchainjs-toolset";
import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";
 
async function runSecureframeAgent() {
  // 1. Initialize the Tool Manager for your specific Secureframe account
  const toolManager = new TrutoToolManager({
    apiKey: process.env.TRUTO_API_KEY,
    integratedAccountId: "YOUR_SECUREFRAME_ACCOUNT_ID",
  });
 
  // 2. Fetch all proxy tools natively formatted for OpenAI
  const tools = await toolManager.getTools();
 
  // 3. Initialize the LLM and bind the tools
  const llm = new ChatOpenAI({
    modelName: "gpt-4o",
    temperature: 0,
  }).bindTools(tools);
 
  // 4. Setup the agent prompt
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a senior compliance automation agent. You manage Secureframe environments. When querying endpoints that require the 'q' parameter, you must strictly use valid Lucene syntax. Framework Asset Scopes are immutable - you must create new ones to change states."],
    ["human", "{input}"],
    ["placeholder", "{agent_scratchpad}"],
  ]);
 
  // 5. Create the Agent and Executor
  const agent = await createOpenAIToolsAgent({
    llm,
    tools,
    prompt,
  });
 
  const executor = new AgentExecutor({
    agent,
    tools,
    maxIterations: 10,
  });
 
  // 6. Execute with custom Rate Limit handling
  try {
    const result = await executor.invoke({
      input: "List all Secureframe cloud resources in the us-east-1 region that are currently out of the audit scope."
    });
    console.log(result.output);
  } catch (error: any) {
    if (error.response?.status === 429) {
      // Truto passes the 429 downstream and normalizes the headers
      const resetTime = error.response.headers['ratelimit-reset'];
      console.warn(`Rate limited by Secureframe. Wait ${resetTime} seconds before retrying.`);
      // Implement your custom backoff/retry logic here
    } else {
      console.error("Agent execution failed:", error);
    }
  }
}
 
runSecureframeAgent();

This architecture guarantees that your agent has access to exactly what Secureframe allows, defined by structured schemas, without requiring you to write thousands of lines of TypeScript boilerplate to handle OAuth handshakes and URL formatting.

If you want to scale autonomous security, maintaining custom integrations is a losing battle. You might also explore building MCP servers to standardize how your agents interact with your security stack. By relying on managed proxy APIs, you separate the volatile business logic of compliance platforms from your core agent execution loop. This approach ensures your engineering team spends their time building better AI workflows, rather than reading API deprecation emails and debugging Lucene syntax errors.

FAQ

Does Truto automatically handle Secureframe rate limits?
No. Truto passes HTTP 429 errors directly to the caller. However, it normalizes the upstream rate limit data into standard headers (ratelimit-limit, ratelimit-remaining, ratelimit-reset) so your agent execution loop can handle backoff and retries programmatically.
How do AI agents interact with Secureframe's Lucene search parameters?
Secureframe uses the 'q' parameter for Lucene syntax filtering. Truto's proxy API schemas define this clearly, but you must provide system prompt instructions to your LLM ensuring it formats the query string correctly (e.g., q=vendor_name:aws AND in_audit_scope:false).
Can an AI agent update an existing Framework Asset Scope in Secureframe?
No. Framework Asset Scopes in Secureframe are entirely immutable. To change an asset's scope, the AI agent must use the create tool to generate a new scope record targeting the resource.
Which agent frameworks are supported by Truto's tool endpoint?
Truto's /tools endpoint returns standard JSON schemas that can be parsed by any framework. Truto provides a native SDK for LangChain.js, but the output works natively with LangGraph, CrewAI, Vercel AI SDK, or custom execution loops.

More from our Blog