Cresta Software Engineer Interview Experience — AI-Assisted Coding Round: Build a Flight-Booking Chat Agent in Python

Cresta·Software Engineer·Sep 2026
Onsitemedium

You get an api.md doc plus an agent_starter.py file, and you have to use AI assistance to implement an AI Agent that searches for and books flights. The format is a chat dialog.

Note: the language has to be Python, and you need to set up the whole project in your own IDE, so make sure you can actually run Python locally first. They'll also give you OPENAI_API_KEY, OPENAI_BASE_URL, and FLIGHT_API_KEY.

api.md

  1. Save Passenger Information

POST /api/save_passenger_information

Request:

{ "first_name": "John", "last_name": "Doe", "email": "<email>", "phone": "<phone>", "date_of_birth": "1990-05-15" }

Response (save passenger_id):

{ "success": true, "passenger_id": "<passenger-uuid>", "message": "Passenger information saved successfully" }
  1. Search Flights

POST /api/search_flight

Request:

{ "origin": "JFK", "destination": "LAX", "departure_date": "2025-11-15", "passengers": 1 }

Response (save flight_id from selected flight):

{ "success": true, "flights": [ { "flight_id": "FLABCD1234", "flight_number": "AA123", "airline": "American Airlines", "departure_time": "2025-11-15T08:00:00", "arrival_time": "2025-11-15T11:30:00", "price": 299.99, "available": true } ], "total_results": 20 }
  1. Book Flight

POST /api/book_flight

Request (use IDs from steps 1 & 2):

{ "passenger_id": "<passenger-uuid>", "flight_id": "FLABCD1234", "seat_preference": "window" }

Response (save confirmation_code):

{ "success": true, "booking_id": "<booking-uuid>", "confirmation_code": "A7B3C9", "booking_details": { "pricing": { "total_price": 344.99 } } }

Authentication Example

headers = { "X-API-Key": "your-api-key-here", "Content-Type": "application/json" }

agent_starter.py

#!/usr/bin/env python3
"""
Flight Booking Agent Starter Template
"""

import os
import json
import requests
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

# Configuration
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
FLIGHT_API_KEY = os.getenv("FLIGHT_API_KEY", "")
API_BASE_URL = "<flight API base URL>"

client = OpenAI(api_key=OPENAI_API_KEY)

# System prompt - modify as needed
SYSTEM_PROMPT = "You are a helpful flight booking assistant."

# Welcome message
WELCOME_MESSAGE = """Welcome to the Flight Booking Agent!
I can help you book flights. Just tell me where you'd like to go.
Type 'quit' to exit."""

# Define your tools here
TOOLS = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City name or zip code"
                    },
                    "units": {
                        "type": "string",
                        "enum": ["celsius", "fahrenheit"],
                        "description": "Temperature unit"
                    }
                },
                "required": ["location"],
                "additionalProperties": False
            }
        }
    }
]


def execute_function(function_name: str, arguments: dict) -> dict:
    """Execute API calls based on function name"""
    # Call your functions here

    return {"error": "Not implemented"}


def run_agent():
    """Main conversation loop"""
    messages = [{"role": "system", "content": SYSTEM_PROMPT}]

    print(f"\n{WELCOME_MESSAGE}\n")

    while True:
        user_input = input("You: ").strip()

        if user_input.lower() in ['quit', 'exit']:
            break

        if not user_input:
            continue

        messages.append({"role": "user", "content": user_input})

        # Call LLM
        response = client.chat.completions.create(
            model="gpt-4.1",
            messages=messages,
            tools=TOOLS if TOOLS else None
        )

        assistant_message = response.choices[0].message

        # Handle function calls
        if assistant_message.tool_calls:
            messages.append(assistant_message)

            for tool_call in assistant_message.tool_calls:
                result = execute_function(
                    tool_call.function.name,
                    json.loads(tool_call.function.arguments)
                )
                messages.append({
                    "role": "tool",
                    "tool_call_id": tool_call.id,
                    "name": tool_call.function.name,
                    "content": json.dumps(result)
                })

            # Get response after function execution
            response = client.chat.completions.create(
                model="gpt-4.1",
                messages=messages
            )
            assistant_message = response.choices[0].message

        messages.append(assistant_message)
        print(f"\nAgent: {assistant_message.content}\n")


if __name__ == "__main__":
    run_agent()

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
Cresta
Role
Software Engineer
Rounds
Onsite
Difficulty
medium
Interview date
Sep 2026
Questions from this interview
1 question

Real Cresta interview experiences

First-hand reports from Cresta candidates — the rounds, the questions they were asked, and how it went.

All 6 Cresta interview experiences