Both by Tamora Pierce.
Oh boy. Here come a bunch of posts.
Aly seems at first to be the consumnate spy; only sixteen years old, she stubbornly runs away, supposedly to give her parents some time alone, and she ends up captured by pirates and conscripted by Kyprioth, the one-time god of the Copper Isles, to protect and serve the descendants of the native royal family. How's that for a run-on sentence?
She still seems, maybe, a little too perfect, but her flaws were more apparent on a second reading: she has all of the emotional maturity you might expect of a 16-year-old... which is to say, not as much as might be hoped. She rushes into all sorts of things without thinking much and faces blades at her throat with calm advice about the fastest way to kill her. Well, one blade, anyway.
In short, this is a fairly light-hearted story set in the world of Tortall. The characters don't really change or grow all that much; Aly manages to confront and overcome her own misconceptions but otherwise remains much the same throughout. Her playacting with Taybur ("I'm only a maid, sir! Please, sir, I don't know what you're talking about!") and his responses ("Let's pretend you've already given the 'I don't know what you're talking about' speech and proceed from there") are possibly the most amusing part of either book.
In fact, Taybur is perhaps a little too perfect himself. Faultlessly loyal and vigilant; what more could a king ask of his guard? Well... read the story and find out.