File size: 2,672 Bytes
0082e2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625b444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
title: Meta OpenEnv Hackathon  AI Agent Submission
emoji: 🚀
colorFrom: blue
colorTo: purple
sdk: python
license: mit
tags:
  - openenv
  - ai
  - hackathon
  - qwen
  - huggingface
---

# Meta OpenEnv Hackathon — AI Agent Submission

## Overview

This project is a production-ready AI agent built for the **Meta OpenEnv Hackathon**. The agent competes in a 3-round coding challenge against an OpenAI GPT-4o-mini judge, receiving Python coding tasks and submitting solutions for evaluation.

---

## Agent: `inference.py`

The core agent logic lives entirely in `inference.py`. It runs a 3-round loop that:

1. Calls the local OpenEnv server's `/reset` endpoint to fetch a new coding task
2. Sends the task to a powerful LLM to generate a Python solution
3. Submits the solution back to the `/step` endpoint and retrieves the score

### API Payload Compatibility

The agent uses the exact payload format required by the Meta OpenEnv REST API:

```json
{"action": {"answer": "<agent_answer>"}}
```

This nested structure matches the server's strict Pydantic model validation, completely preventing `422 Unprocessable Entity` errors that arise from incorrect top-level keys or flat payload formats.

---

## Model: Qwen/Qwen2.5-72B-Instruct

The agent uses **`Qwen/Qwen2.5-72B-Instruct`** via the **Hugging Face Router API** (`https://router.huggingface.co/v1`), accessed through an OpenAI-compatible client.

Key reasons for this choice:

- The HF Router endpoint is the current active inference gateway — the legacy `api-inference.huggingface.co/v1` endpoint has been deprecated and returns `410 Gone` errors
- Qwen 2.5 72B delivers state-of-the-art Python code generation, significantly outperforming smaller models on structured coding tasks
- The OpenAI-compatible interface ensures zero-downtime, stable connections with clean error handling

---

## Task Parsing

The agent safely parses tasks from multiple possible server response shapes:

- `response["observation"]["echoed_message"]`
- `response["observation"]["task_prompt"]`
- `response["echoed_message"]`
- Raw JSON fallback via `json.dumps(resp)`

This makes the agent resilient to any OpenEnv server version or configuration.

---

## Setup

### 1. Install dependencies

```bash
pip install -r requirements.txt
```

### 2. Set environment variables

```powershell
$env:HF_TOKEN = "hf_your_token_here"
$env:OPENAI_API_KEY = "sk-your_key_here"
```

### 3. Start the OpenEnv server, then run the agent

```bash
python inference.py
```

---

## Requirements

| Package      | Version  |
|--------------|----------|
| requests     | 2.31.0   |
| openai       | 1.14.0   |
| pydantic     | 2.6.4    |