Skip to content

Latest commit

 

History

History
147 lines (124 loc) · 3.61 KB

File metadata and controls

147 lines (124 loc) · 3.61 KB

Macro DSL Specification for AI Agents

Overview

This specification defines a macro DSL (Domain-Specific Language) for AI agents (e.g., Claude, Mistral, Copilot) built on top of the 007 language. The goal is to simplify 007 for AI agents while preserving its safety and verification features.

Key Features

1. Syntactic Sugar

Provide shortcuts for common AI agent patterns:

  • @api_call: Simplify API interactions.
  • @tool_use: Standardize tool usage.
  • @agent: Quick agent creation with default capabilities.

2. Predefined Protocols

Standardize session types for common AI tasks:

  • QAProtocol: Question-answering workflows.
  • SummarizationProtocol: Text summarization tasks.
  • RetrievalProtocol: Information retrieval workflows.

3. Capability Templates

Reusable capability sets for AI agents:

  • WebSearch: Capabilities for web searches.
  • CodeGeneration: Capabilities for code generation.
  • DataAnalysis: Capabilities for data analysis.

Macro Definitions

@api_call

Simplifies API interactions:

macro @api_call(endpoint: String, params: Data) {
  @impure control {
    let response = call_api(endpoint, params)
    return response
  }
}

@tool_use

Standardizes tool usage:

macro @tool_use(tool: String, input: Data) {
  @impure control {
    let result = use_tool(tool, input)
    return result
  }
}

@agent

Quick agent creation:

macro @agent(name: String, caps: [Cap]) {
  agent name(caps: caps) {
    @total data state = {}
    @impure control {
      on receive(msg) -> handle(msg)
    }
  }
}

Predefined Protocols

QAProtocol

Question-answering workflow:

session protocol QAProtocol {
  User -> Agent: Query(question: String)
  Agent -> User: Answer(response: String)
}

SummarizationProtocol

Text summarization task:

session protocol SummarizationProtocol {
  User -> Agent: Summarize(text: String)
  Agent -> User: Summary(summary: String)
}

RetrievalProtocol

Information retrieval workflow:

session protocol RetrievalProtocol {
  User -> Agent: Retrieve(query: String)
  Agent -> User: Results(results: [Data])
}

Capability Templates

WebSearch

Capabilities for web searches:

capability WebSearch = [web_fetch, web_search]

CodeGeneration

Capabilities for code generation:

capability CodeGeneration = [execute, read_file, write_file]

DataAnalysis

Capabilities for data analysis:

capability DataAnalysis = [read_file, compute, visualize]

Example Workflows

Retrieval-Augmented Generation

choreography retrieval_augmented_generation(
  user: Agent<User>,
  retriever: Agent<Retriever>,
  generator: Agent<Generator>
) {
  user -> retriever: Query("What is 007?")
  retriever -> generator: Context(documents: [Data])
  generator -> user: Answer(response: String)
}

Question-Answering

choreography qa_workflow(
  user: Agent<User>,
  agent: Agent<QAAgent>
) {
  user -> agent: Query("What is the capital of France?")
  agent -> user: Answer("Paris")
}

Implementation Steps

  1. Define Macros: Create macros for common AI tasks.
  2. Predefined Protocols: Standardize session types for AI workflows.
  3. Capability Templates: Define reusable capability sets.
  4. Tooling: Build a preprocessor to expand macros into full 007 code.
  5. Testing: Test with example AI workflows (QA, summarization).

Conclusion

This macro DSL simplifies 007 for AI agents while preserving its safety and verification features. It provides syntactic sugar, predefined protocols, and capability templates to make 007 practical for modern AI workflows.