Midio docs
  • Getting Started
    • Welcome
    • Quick Start Guide
  • Your First Midio App
  • Guides
    • HTTP
      • Making HTTP Requests
      • Responding to HTTP Requests
      • How to reach your own endpoints
      • CORS
      • Server-Sent Events (SSE)
    • Branching
    • Loops
    • Map, filter, reduce
    • Working with Data
    • Expressions
    • Building Agents
      • Streaming Agent API (experimental)
    • Debugging
    • Secrets and Environment variables
    • Convert JSON to data nodes
    • Writing tests
    • Cleaning up your flows
  • Package Manager
  • Integrating with third party services
  • Troubleshooting
  • Tutorials
    • Connecting LLMs to MCP-servers using the MCP-client package
    • Making Your Own MCP Server in Midio
    • A Fast Path to Functional RAG Agents
    • How to build a streaming agent using Server-Sent Events (SSE)
  • Reference
    • The Midio Editor
      • The Node Editor
      • User Traces
      • Traces (execution)
      • Processes
      • Log
      • Services
      • Problems
      • Function Signature
      • Data
      • Settings
    • The Midio Language
      • Nodes and execution
      • Functions and Events
        • Anonymous functions
      • Modules
      • Contexts
      • Data type
      • Local variables
      • Portals
      • Waypoint node
      • Partial function application
  • The Midio Engine
  • Built in Nodes
    • Core (std)
    • HTTP
    • LLM
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Reference
  2. The Midio Language

Contexts

PreviousModulesNextData type

Last updated 2 months ago

Was this helpful?

Contexts provide a way for nodes to implicitly pass values along an execution path, eliminating the need for explicit connections. For example, when an node receives a request, it automatically makes an EndpointContext available to nodes it connects to. This allows an node to access and respond to the request without requiring you to explicitly pass a request object.

Some input triggers require specific contexts to function. These triggers either consume or borrow contexts:

  • Consuming a context means it can only be used once. For example, Http.Response.execute consumes an EndpointContext, ensuring that a request can only be responded to once.

  • Borrowing a context means it can be used multiple times without consuming it. For example, Testing.AssertEqual.execute borrows a TestContext, allowing multiple assertions within the same test.

Some examples of functions in the standard library using contexts

Contexts in user defined functions

provides an EndpointContext, representing the incoming HTTP request, which is then consumed by the first call to .

provides a TestContext, representing a running test instance. This context is then borrowed by assertion functions like .

provides a context which keeps track of the current loop index.

If your own functions use functions that require certain contexts, you need to explicitly add those contexts to your own functions triggers as well. If you for example want to perform an call in your function, you need consume an EndpointContext.

Http Endpoint
Http Response
Http Response
Http Endpoint
Http Response
You can check what contexts a trigger produces by hovering over its output.
Click the + icon in the input trigger and search for EndpointContext.
Testing Test
Std AssertEqual
Std For